hwnd = CreateWindowEx(
0, // no extended styles
g_szWindowClass, // global string containing name of window class
g_szTitle, // global string containing title bar text
WS_OVERLAPPEDWINDOW |
WS_HSCROLL | WS_VSCROLL, // window styles
CW_USEDEFAULT, // default horizontal position
CW_USEDEFAULT, // default vertical position
CW_USEDEFAULT, // default width
CW_USEDEFAULT, // default height
(HWND) NULL, // no parent for overlapped windows
(HMENU) NULL, // use the window class menu
g_hInst, // global instance handle
(PVOID) NULL // pointer not needed
);
我直接从http://msdn.microsoft.com/en-us/library/windows/desktop/hh298376%28v=vs.85%29.aspx
复制并粘贴但是,以'g_'开头的变量是未定义的,我该如何定义它们?我没有在Microsoft网站上找到该信息。
哦,我的目标也是创建一个滚动条。 (垂直)
谢谢
答案 0 :(得分:0)
g_表示全局变量;将前缀为_g的3个变量声明为全局变量。设置
wchar_t g_szClassName[] = L"WindowClassName";
g_szTitle = L"Name"; // use this
g_hInst = thisInstance; // one of mains parameters
这样的事情: //这是unicode。
wchar_t szClassName[] = L"ClassRegisterName";
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) {
...
hwnd = CreateWindow(szClassName, L"Your Title", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_CLIPCHILDREN,
100, 50, 100, 100, NULL, NULL, hThisInstance, NULL);