Here is a very simple WinLIFT-64 window Template
// HelloWin.cpp
// compile with: /D_UNICODE /DUNICODE /DWIN32 /D_WINDOWS /c
#include "stdafx.h"
#include <windows.h>
#include <Commctrl.h>
#include <vector>
#pragma comment(lib, "D:\\VS2010\\WinLIFT64.lib")
#pragma comment(lib, "D:\\VS2010\\WinLIFT32.lib")
#include "WinLIFT.h"
#define MyWindowWidth 800
#define MyWindowHeight 540
#define IDC_MAIN_STATICIMG 1009
// Main winproc
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
long wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (uMsg)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
return 0;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: process here the WM_PAINT message...
EndPaint(hWnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// Declaration of local variables
long nRet = 0, IsInitialized = 0;
WNDCLASSEX wcx; MSG msg;
WCHAR szWindowClass[] = L"WLFT";
WCHAR szTitle[64];
if (sizeof(LONG_PTR) == 8) {
wcscpy_s(szTitle, L"WinLIFT-64 Template"); }
else {
wcscpy_s(szTitle, L"WinLIFT-32 Template");
}
// Register the main window class
wcx.cbSize = sizeof(WNDCLASSEX);
IsInitialized = GetClassInfoEx(hInstance, szWindowClass, &wcx);
if (!IsInitialized)
{
wcx.style = CS_HREDRAW | CS_VREDRAW;
wcx.lpfnWndProc = WndProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = hInstance;
wcx.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcx.lpszMenuName = NULL;
wcx.lpszClassName = szWindowClass;
wcx.hIconSm = LoadIcon(wcx.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
if (RegisterClassEx(&wcx)) { IsInitialized = -1; }
}
if (IsInitialized) {
long w = MyWindowWidth;
long h = MyWindowHeight;
long x = max((GetSystemMetrics(SM_CXSCREEN) - w) / 2, 0);
long y = max((GetSystemMetrics(SM_CYSCREEN) - h) / 2, 0);
DWORD dwStyle = WS_POPUP | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
WS_MAXIMIZEBOX | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // | WS_VISIBLE
HWND hWnd = CreateWindowEx(
0, // Optional window styles.
szWindowClass, // Window class
szTitle, // Window text
dwStyle, // Window style
// Size and position
x, y, w, h,
NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);
if (hWnd) {
wstring sExePath;
WCHAR exepath[MAX_PATH];
if (GetModuleFileName(0, exepath, sizeof(exepath))) {
sExePath = exepath; sExePath = sExePath.substr( 0, sExePath.rfind(L"\\")); sExePath += L"\\";
}
wstring SkinTheme = sExePath; SkinTheme += L"Sony.sks";
if (skInitEngine ((WCHAR*) SkinTheme.c_str(), L"")) {
skSkinWindow(hWnd, L"Dock|Undock|Minimize|Maximize|Restore|Close");
// Optional WinLIFT static image background.
wstring sResource = sExePath; sResource += L"Resource\\Assistant.png";
HWND hCtrl = skStaticImage (hWnd, (WCHAR*) sResource.c_str(), 580, 20, 185, 456, IDC_MAIN_STATICIMG);
skSetAnchorCtrl(hCtrl, ANCHOR_HEIGHT_RIGHT);
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
// Main message loop
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
nRet = (long) msg.wParam;
}
}
return nRet;
}
The full VS2010 C++ project is attached to this post (See the Release folder to run the EXE demo)
Added: 32-bit version in HelloWin32.zip
TIP to change the WinLIFT window background on the fly .
Edit the
.sks file, and customize the
BACKGROUNDPATH parameter to use a specific image folder.
Then you will be able to use them as background, and to select one: click with the left or right mouse button on the top-left WinLIFT icon.
Quote
'AUTHOR section -------------------------------------------------------------
"AUTHOR,|Skin design: <Patrice Terrier> E-mail: pterrier@zapsolution.com"
"BACKGROUNDPATH, C:\Users\Public\Pictures\Sample Pictures"
'BITMAP section -------------------------------------------------------------
"CTLBACK, @PATH@Sony\CTLBACK.jpg"
"MENUBAR, @PATH@Sony\MENUBAR.ski"
"MENUBACK, @PATH@Sony\MENUBAK.ski"
"BUTTON, @PATH@Sony\BUTTON.ski"
"CAPTIONL, @PATH@Sony\CAPTIONL.ski"
"CAPTIONM, @PATH@Sony\CAPTIONM.ski"
"CAPTIONR, @PATH@Sony\CAPTIONR.ski"
"SIDEL, @PATH@Sony\SIDEL.ski"
"SIDER, @PATH@Sony\SIDER.ski"
"RADIOBUT, @PATH@Sony\RADIOBUT.ski"
"CHECKBUT, @PATH@Sony\CHECKBUT.ski"
"CAPLED, @PATH@Sony\BTN_Led.ski"
"PROGRESS, @PATH@Sony\PROGRESS.ski"
"CPOPUPR, @PATH@Sony\CPOPUPR.ski"
"BOTTOML, @PATH@Sony\BOTTOML.ski"
"BOTTOMM, @PATH@Sony\BOTTOMM.ski"
"BOTTOMR, @PATH@Sony\BOTTOMR.ski"
"SYSCLOSE, @PATH@Sony\BTN_Close.ski"
"SYSRESTORE, @PATH@Sony\BTN_Restore.ski"
"SYSMINIMIZE, @PATH@Sony\BTN_Minimize.ski"
"SYSMAXIMIZE, @PATH@Sony\BTN_Maximize.ski"
"TABBUTTON, @PATH@Sony\TABBUTTON.ski" ' 4.01
"HORZBAR, @PATH@Sony\HORZBAR.ski" ' 4.20
"VERTBAR, @PATH@Sony\VERTBAR.ski" ' 4.20
"SBPICTO, @PATH@Sony\SBPICTO.ski" ' 4.20 ScrollBar picto
"DRAGWIN, @PATH@Sony\DRAGWIN.ski" ' 4.17
"BTNTRACK, @PATH@Sony\BTNTRACK.ski" ' 4.26 TrackBar thumb button
"MENUNAV, @PATH@Sony\MENUNAV.ski" ' 4.35
"ICON_PROG, @PATH@Sony\ICON.ski" ' 4.38
"ICON_ALERT, @PATH@Sony\ICON_Alert.ski"' 4.38
"ICON_ERROR, @PATH@Sony\ICON_Error.ski"' 4.38
"ICON_INFO, @PATH@Sony\ICON_Info.ski" ' 4.38
"ICON_INPUT, @PATH@Sony\ICON_Input.ski"' 4.38
"DLG_ALERT, @PATH@Sony\DLG_Alert.ski" ' 4.38
"DLG_INPUT, @PATH@Sony\DLG_Input.ski" ' 4.38
"DLG_INFO, @PATH@Sony\DLG_Info.ski" ' 4.38
'SIZE & COORDINATES section -------------------------------------------------
"CYSTATUS, 18" ' SIZE: height of status bar. Std = 18
"CXSIZE, 18" ' SIZE: X size of system buttons. Std = 18
"CYSIZE, 18" ' SIZE: Y size of system button. Std = 18
"CXSYSBUT, 17" ' Sys buttons X offset from right side.
"CYSYSBUT, 23" ' Sys buttons Y offset from top side.
"CXCAPTEXT, 60" ' Caption text X offset from left side
"CYCAPTEXT, 25" ' SIZE: Y pos of caption text
"CXSYSLED, 40" ' Led X offset from right side.
"CYSYSLED, 56" ' Led Y offset from top side.
"XBUT3DBORDER, 06" ' Horizontal non stretched button border
"YBUT3DBORDER, 06" ' Vertical non stretched button border
"CXSYSICON, 24" ' SIZE: X pos of system icon.
"CYSYSICON, 20" ' SIZE: Y pos of system icon.
"ICONSIZE, 30" ' The icon size.
"PAINT_BORDER, 2" ' 0 = %PAINT_TILING_MODE, 1 = %PAINT_STRETCH_MODE, 2 = %PAINT_STRETCH_LEFT_RIGHT, 4 = %PAINT_STRETCH_TOP_BOTTOM
"PAINT_BACKGROUND, 1" ' 0 = %PAINT_TILING_MODE, 1 = %PAINT_STRETCH_MODE
"OUTER_GLOW, 1" ' 0 = OFF, 1 = ON (Caption + PushButton)
"SKIN_ICON, 1" ' 0 = OFF, 1 = ON (Display skin icon on caption instead of default)
'COLOR section --------------------------------------------------------------
"CAPTIONTEXT, 255,240,240,240" ' RGB active caption text color.
"INACTIVECAPTIONTEXT, 255,110,113,117" ' RGB inactive caption text color.
"ACTIVECAPTION, 255,224,223,227" ' RGB active caption background color.
"INACTIVECAPTION, 255,235,235,235" ' RGB inactive caption background color.
"BTNTEXT, 255,230,230,230" ' RGB font color to use in button.
"POPMENUTEXT, 255,192,192,192" ' RGB PopMenu.
"POPMENUHILITE, 255,32,32,32" ' RGB PopMenu 3D color.
"WINDOWTEXT, 255,230,230,230" ' RGB default main window text color.
"HILITEBACK, 255,209,209,209" ' RGB active item background in control.
"HILITETEXT, 255,64,64,64" ' RGB active item text in control.
"ACTIVMENU, 255,250,250,250" ' RGB active menu bar text color.
"INACTIVMENU, 255,133,138,133" ' RGB inactive menu bar text color.
"MENUBARHILITE, 255,0,0,0" ' 4.35 RGB menu bar hilite.
"GRAYEDCOLOR, 255,128,128,128" ' 4.53 for grayed text control.
"3DLEFTTOP, 255,58,58,58" ' RGB skDrawRect3D left top color.
"3DRIGHTBOTTOM, 255,126,126,126" ' RGB skDrawRect3D right bottom color.
"CARETCOLOR, 255,128,0,0" ' 4.36+ RGB caret color.
"EDITCOLORTEXT, 255,220,220,220" ' 4.01+ RGB Edit text color.
"EDITCOLORBACK, 255,110,113,117" ' 4.01+ RGB Edit background color.
"EDITCOLORRECTUP, 255,192,192,192" ' 4.01+ RGB Edit frame top/left color.
"EDITCOLORRECTDOWN, 255,192,192,192" ' 4.01+ RGB Edit frame bottom/right color.
"MENUBORDERFRAME, 255,32,32,32" ' 4.01+ RGB Menu frame border color.
"TBTRACKCOLOR, 255,160,160,160" ' 4.26 Track bar hilight color
"TBPOSCOLOR, 255,0,74,201" ' 4.26 Track bar progress color
"SHADOW, 255,0,0,0" ' RGB shadow item translucent color. 128,128,128
"TRANSLUCENCY, 70" ' Shadow translucency.
"MENUTRANSLUCENCY, 90" ' Menu translucency percentage
"DWM_AERO, 0" ' 4.70, 0 = OFF, 1 = ON (Use VISTA-SEVEN Aero composited mode)
"DWM_LEFT, 00" ' 4.70, DWM left border size.
"DWM_TOP, 00" ' 4.70, DWM top border size.
"DWM_RIGHT, 00" ' 4.70, DWM right border size.
"DWM_BOTTOM, 00" ' 4.70, DWM bottom border size.
"AEROCOLOR, 000,000,000,000" ' 4.70, ARGB color to paint behind transparent background.
Attached are 2 images that would look great with the Sony skin, either as Windows desktop wallpaper or as internal WinLIFT background (remember you can change the WinLIFT background from the top-left icon)
Patrice,
Thank you.
If possible would you do exact the same package as this in 32bit?
James
James--
I have attached HelloWin32.zip to the first post of this thread.
Note: The source code for 32 and 64-bit is strictly the same.
...
Patrice,
You are using UNICODE in both 32 and 64 bit ?
If so why?
James
Because Unicode is now the Windows native mode, and because i want to maintain only one source code. :)
Unicode has been part of the core API since 10 years now, and a good example of that is GDIPLUS that has been released in 2003.
Patrice,
I know José has been preaching using UNICODE for decades(?) :) but I see very little in use with PowerBASIC samples or
even any c/c++ sites that have general windows examples. It is a double difficult task for PowerBASIC users to first convert
code to UNICODE and then to c/c++.
Petzold in the dated fifth addition does have a short unicode chapter and points the way.
I think the way to go is to let the compiler decide by including <tchar.h> and <wctype.h> and using _TCHAR* for char*, and wrap all literals with _T("hello") rather than prefix with L. That way you can use both ASCII and UNICODE.
To that end a unicode lexer was written to take standard ascii c/c++ code and produce UNICODE/ASCII.
http://ian.bcxbasic.com/Ian%27s%20Unicode%20Programming.html
I have been testing with MINGW and VC++ (Win7 SDK) and it appears to work fine.
Patrice, while you may not need it as your 32/64 code is already written maybe the lurkers will find it useful.
James
Most of my users, are from PC-Soft, and there is now a WinDev version in Mandarin, thus the use of unicode is a mandatory for my tools, especially for the 64-bit version.
And because i am rewriting everything, it is also the good timing to move to the current standard.
Here is a snippet that illustrates unicode or ascii using <tchar.h>
James
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
#define _UNICODE
#endif
#include <tchar.h>
#include <wctype.h>
#include <iostream>
#ifdef UNICODE
#define _tcout std::wcout
#else
#define _tcout std::cout
#endif // UNICODE
int _tmain()
{
_tcout << _T("Hello world!") << std::endl;
return 0;
}