这篇教程C++ CreateWindow函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CreateWindow函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateWindow函数的具体用法?C++ CreateWindow怎么用?C++ CreateWindow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CreateWindow函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: insert_dlg_procLRESULT CALLBACK insert_dlg_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){ static TABLE_WINDOW *win=0; static HWND hlistview=0,hgrippy=0,hedit=0; static HFONT hfont=0; static WNDPROC origlistview=0; if(FALSE) { static DWORD tick=0; if((GetTickCount()-tick)>500) printf("--/n"); if(hwnd==hlistview) printf("-"); print_msg(msg,lparam,wparam,hwnd); tick=GetTickCount(); } if(origlistview!=0 && hwnd==hlistview){ if(msg==WM_GETDLGCODE){ return DLGC_WANTARROWS; } return CallWindowProc(origlistview,hwnd,msg,wparam,lparam); } switch(msg){ case WM_INITDIALOG: if(lparam==0){ EndDialog(hwnd,0); break; } hedit=0; win=lparam; hlistview=CreateWindow(WC_LISTVIEW,"",WS_TABSTOP|WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE|LVS_REPORT|LVS_SHOWSELALWAYS, 0,0, 0,0, hwnd, IDC_LIST1, ghinstance, NULL); if(hlistview!=0){ ListView_SetExtendedListViewStyle(hlistview,LVS_EX_FULLROWSELECT); hfont=SendMessage(win->hlistview,WM_GETFONT,0,0); if(hfont!=0) SendMessage(hlistview,WM_SETFONT,hfont,0); populate_insert_dlg(hwnd,hlistview,win); ListView_SetItemState(hlistview,0,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED); origlistview=SetWindowLong(hlistview,GWL_WNDPROC,(LONG)insert_dlg_proc); } set_title(hwnd,win); hgrippy=create_grippy(hwnd); resize_insert_dlg(hwnd); break; case WM_NOTIFY: { NMHDR *nmhdr=lparam; if(nmhdr!=0){ switch(nmhdr->code){ case NM_DBLCLK: if(hedit==0 && nmhdr->hwndFrom==hlistview) SendMessage(hwnd,WM_COMMAND,IDOK,0); break; case LVN_COLUMNCLICK: { static sort_dir=0; NMLISTVIEW *nmlv=lparam; if(nmlv!=0){ sort_listview(hlistview,sort_dir,nmlv->iSubItem); sort_dir=!sort_dir; } } break; case LVN_KEYDOWN: if(nmhdr->hwndFrom==hlistview) { LV_KEYDOWN *key=lparam; switch(key->wVKey){ case VK_DOWN: case VK_RIGHT: case VK_NEXT: { int count,row_sel; count=ListView_GetItemCount(hlistview); row_sel=ListView_GetSelectionMark(hlistview); if(count>0 && row_sel==count-1) SetFocus(GetDlgItem(hwnd,IDOK)); } break; case VK_DELETE: clear_selected_items(hlistview); break; case VK_F5: if(task_insert_row(win,hlistview)) SetWindowText(GetDlgItem(hwnd,IDOK),"Busy"); break; case 'A': if(GetKeyState(VK_CONTROL)&0x8000){ int i,count; count=ListView_GetItemCount(hlistview); for(i=0;i<count;i++){ ListView_SetItemState(hlistview,i,LVIS_SELECTED,LVIS_SELECTED); } break;//.........这里部分代码省略.........
开发者ID:pinchyCZN,项目名称:DB_UTIL,代码行数:101,
示例2: WinProcLRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam){ static string in_encr, in_decr, pb_key, pr_key, key, out; static RECT clientRect = { 0 }; static RECT textRect1; static RECT textRect2; static RECT textRect3; static int xEncrypt, yEncrypt; static int xDecrypt, yDecrypt; static int xGenerate, yGenerate; static HWND EncryptButton = NULL; static HWND DecryptButton = NULL; static HWND GenerateButton = NULL; static HWND ChooseEncrButton = NULL; static HWND ChooseDecrButton = NULL; static HWND ChooseKeyButton = NULL; static HWND HelpWindow = NULL; static HWND EncryptTextField = NULL; static HWND DecryptTextField = NULL; static HWND KeyTextField = NULL; static HDC hDCScreen = GetDC(NULL); static int Horres = GetDeviceCaps(hDCScreen, HORZRES); static int Vertres = GetDeviceCaps(hDCScreen, VERTRES); HDC hdc = NULL; PAINTSTRUCT paintStruct; // A PAINTSTRUCT structure is something we need to paint (draw) when handling the WM_PAINT message. PAINTSTRUCT ps; OPENFILENAME open_params = { 0 }; // This structure is used by the either the // GetOpenFileName() function (for opening files) // or the GetSaveFileName() function (for saving files) // We're going to use it for opening a file -- Info about // the file we try to open WILL be stored in this struct char filter[BUFF_MAX] = { 0 }; // This will be filled in with a "filter", explained later :) char file_name[BUFF_MAX] = { 0 }; // This will be used as the "default filename" for the // dialog box wchar_t str[BUFF_MAX]; switch (message) { case WM_CREATE: // This message is sent when the window is created. // We would want to put our initialization code here... GetClientRect(hwnd, &clientRect); DragAcceptFiles(ChooseKeyButton, TRUE); EncryptButton = CreateWindow("Button", "Зашифровать", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)ENCRYPT_BUTTON, ((LPCREATESTRUCT)lparam)->hInstance, NULL); DecryptButton = CreateWindow("Button", "Расшифровать", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)DECRYPT_BUTTON, ((LPCREATESTRUCT)lparam)->hInstance, NULL); GenerateButton = CreateWindow("Button", "Сгенерировать", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)GENERATE_BUTTON, ((LPCREATESTRUCT)lparam)->hInstance, NULL); ChooseEncrButton = CreateWindow("Button", "Выбрать файл", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)CHOOSE_ENCR_BUTTON, ((LPCREATESTRUCT)lparam)->hInstance, NULL); ChooseDecrButton = CreateWindow("Button", "Выбрать файл", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)CHOOSE_DECR_BUTTON, ((LPCREATESTRUCT)lparam)->hInstance, NULL); ChooseKeyButton = CreateWindowEx(WS_EX_ACCEPTFILES, "Button", "Выбрать файл", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)CHOOSE_KEY_BUTTON, ((LPCREATESTRUCT)lparam)->hInstance, NULL); EncryptTextField = CreateWindow("Edit", "", WS_BORDER | WS_CHILD | WS_VISIBLE | NULL | NULL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)TEXT_FIELD, ((LPCREATESTRUCT)lparam)->hInstance, NULL); KeyTextField = CreateWindow("Edit", "", WS_BORDER | WS_CHILD | WS_VISIBLE | NULL | NULL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)TEXT_FIELD, ((LPCREATESTRUCT)lparam)->hInstance, NULL); DecryptTextField = CreateWindow("Edit", "", WS_BORDER | WS_CHILD | WS_VISIBLE | NULL | NULL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)TEXT_FIELD, ((LPCREATESTRUCT)lparam)->hInstance, NULL); break; case WM_GETMINMAXINFO: { MINMAXINFO *minmax = (MINMAXINFO *)lparam; minmax->ptMinTrackSize.x = WINDOW_WIDTH;//.........这里部分代码省略.........
开发者ID:suhockii,项目名称:rsa-encryption,代码行数:101,
示例3: WndProcLRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam){ int nItemCount; int nSelected; int *nIndexes; BOOL bFlag; WCHAR *pszFile; WCHAR *handle; WCHAR *token; Image *imgCurrent; Image out; switch (iMessage) { case WM_CREATE: HANDLE hToken; viewer.changeCaption(L"Preview"); //Create Controls hListLayer = CreateWindow(L"ListBox", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_EXTENDEDSEL | LBS_HASSTRINGS | LBS_NOTIFY | LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT, 0, 80, 240, 420, hWnd, (HMENU)ID_LAYER_LIST, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButtonStart = CreateWindow(L"Button", L"Start", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 80, 40, hWnd, (HMENU)ID_START_BUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButtonSave = CreateWindow(L"Button", L"Save Selected in merged file", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 80, 0, 80, 40, hWnd, (HMENU)ID_SAVE_BUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButtonSaveAll = CreateWindow(L"Button", L"Save All in individual file", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 160, 0, 80, 40, hWnd, (HMENU)ID_SAVE_ALL, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButtonResetAll = CreateWindow(L"Button", L"Erase All", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 0, 40, 80, 40, hWnd, (HMENU)ID_RESET_ALL, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButtonResetSelected = CreateWindow(L"Button", L"Erase Selected", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 80, 40, 80, 40, hWnd, (HMENU)ID_RESET_SEL, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButtonResetUnselected = CreateWindow(L"Button", L"Erase Unelected", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 160, 40, 80, 40, hWnd, (HMENU)ID_RESET_UNSEL, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hFont = CreateFont(16, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 3, 2, 1, FF_ROMAN, L"Segoe UI"); SendMessage(hListLayer, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hButtonStart, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hButtonSave, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hButtonSaveAll, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hButtonResetAll, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hButtonResetSelected, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hButtonResetUnselected, WM_SETFONT, (WPARAM)hFont, TRUE); //Create Events hAttachSucceeded = CreateEvent(NULL, TRUE, FALSE, NULL); hDebugEnd = CreateEvent(NULL, TRUE, FALSE, NULL); hDebugInit = CreateEvent(NULL, TRUE, FALSE, NULL); //Adjust Privileges if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { if (SetPrivilege(hToken, SE_DEBUG_NAME, TRUE)) return 0; else MessageBox(hWnd, L"Fail to get debug privilege!!", L"Error", MB_OK | MB_ICONERROR); } else MessageBox(hWnd, L"Fail to get process token!!", L"Error", MB_OK | MB_ICONERROR); SendMessage(hWnd, WM_DESTROY, 0, 0); return 0; case WM_ACTIVATE: if (wParam == WA_CLICKACTIVE) { viewer.foreground(); SetForegroundWindow(hWnd); SetFocus(hListLayer); } return 0; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_START_BUTTON: if (!bStarted) { hAokanaWnd = FindAokana(&dwThreadID, &dwProcessID); if (dwThreadID != 0) { hDebugThread = CreateThread(NULL, 0, DebugThread, NULL, 0, NULL); WaitForSingleObject(hDebugInit, INFINITE); if (WaitForSingleObject(hAttachSucceeded, 0) != WAIT_OBJECT_0) { SetEvent(hDebugEnd); MessageBox(hWnd, L"Fail to attach process!!", L"Error", MB_OK | MB_ICONERROR); break; } SendMessage(hButtonStart, WM_SETTEXT, 0, (LPARAM)L"Stop"); bStarted = TRUE; } } else { SetEvent(hDebugEnd); WaitForSingleObject(hDebugThread, INFINITE); ResetEvent(hDebugEnd); ResetEvent(hDebugInit); ResetEvent(hAttachSucceeded); CloseHandle(hDebugThread);//.........这里部分代码省略.........
开发者ID:weimingtom,项目名称:AokanaCGExtractor,代码行数:101,
示例4: WinMainint PASCALWinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR CmdLine, int nCmdShow){ MSG msg; /* MSG structure to pass to windows proc */ WNDCLASS wndclass; char *AppName; /* Name for the window */ cbErrHandling (PRINTALL, STOPALL); /* Set library's error handling */ CmdLine = NULL; /* Not used */ AppName = "WINCDEMO"; /* The name of this application */ if(!hPrevInstance) { wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc= MainMessageHandler; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon (hInstance, AppName); wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = GetStockObject (WHITE_BRUSH); wndclass.lpszMenuName = AppName; wndclass.lpszClassName = AppName; RegisterClass (&wndclass); } /* create application's Main window */ hWndMain = CreateWindow (AppName, /* Window class name */ "AInScan Foreground", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, /* Use default X, Y */ CW_USEDEFAULT, /* Use default X, Y */ GetSystemMetrics(SM_CXSIZE) * 12, /* x - fit text */ GetSystemMetrics(SM_CYSIZE) * 20, /* y - fit text */ NULL, /* Parent window's handle */ NULL, /* Default to Class Menu */ hInstance, /* Instance of window */ NULL); /* Create struct for WM_CREATE */ if (hWndMain == NULL) { MessageBox(NULL, "Could not create window in WinMain", NULL, MB_ICONEXCLAMATION); return (1); } ShowWindow(hWndMain, nCmdShow); /* Display main window */ UpdateWindow(hWndMain); /* Start a 500ms timer to update display */// if(!SetTimer(hWndMain, TIMER_NUM, 500, NULL))// {// MessageBox(NULL, "Error starting Windows timer", NULL, MB_OK |// MB_ICONEXCLAMATION); // return (1); // } while(GetMessage(&msg, NULL, 0, 0)) /* Main message loop */ { TranslateMessage(&msg); DispatchMessage(&msg); } UnregisterClass (AppName, hInstance); return (msg.wParam);}
开发者ID:mikanradojevic,项目名称:sdkpub,代码行数:66,
示例5: InitializeAppBOOL InitializeApp(LPSTR lpszCommandLine){ WNDCLASS wc; int cyExecStart, cxExecStart; USHORT TitleLen, cbCopy; HWND hwndFax; // Remove Real Mode Segment Address wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hAppInstance; wc.hIcon = LoadIcon(hAppInstance, MAKEINTRESOURCE(ID_WOWEXEC_ICON)); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = GetStockObject(WHITE_BRUSH); wc.lpszClassName = "WOWExecClass";#ifdef DEBUG wc.lpszMenuName = "MainMenu";#else wc.lpszMenuName = NULL;#endif if (!RegisterClass(&wc)) { OutputDebugString("WOWEXEC: RegisterClass failed/n"); return FALSE; } /* * Guess size for now. */ cyExecStart = GetSystemMetrics(SM_CYMENU) * 6; cxExecStart = GetSystemMetrics(SM_CXSCREEN) / 2; /* Load these strings now. If we need them later, we won't be able to load * them at that time. */ LoadString(hAppInstance, IDS_OOMEXITTITLE, szOOMExitTitle, sizeof(szOOMExitTitle)); LoadString(hAppInstance, IDS_OOMEXITMSG, szOOMExitMsg, sizeof(szOOMExitMsg)); LoadString(hAppInstance, IDS_APPTITLE, szAppTitleBuffer, sizeof(szAppTitleBuffer)); ghwndMain = CreateWindow("WOWExecClass", lpszAppTitle, WS_OVERLAPPED | WS_CAPTION | WS_BORDER | WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_SYSMENU, 30, 30, cxExecStart, cyExecStart, NULL, NULL, hAppInstance, NULL); if (ghwndMain == NULL ) {#ifdef DEBUG OutputDebugString("WOWEXEC: ghwndMain Null/n");#endif return FALSE; } hwndFax = FaxInit(hAppInstance); // // Give our window handle to BaseSrv, which will post WM_WOWEXECSTARTAPP // messages when we have commands to pick up. The return value tells // us if we are the shared WOW VDM or not (a seperate WOW VDM). // We also pick up the ShowWindow parameter (SW_SHOW, SW_MINIMIZED, etc) // for the first WOW app here. Subsequent ones we get from BaseSrv. // // // gwFirstCmdShow is no longer used, and is available. // gfSharedWOW = WOWRegisterShellWindowHandle(ghwndMain, &gwFirstCmdShow, hwndFax ); // // If this isn't the shared WOW, tell the kernel to exit when the // last app (except WowExec) exits. // if (!gfSharedWOW) { WowSetExitOnLastApp(TRUE); } /* Remember the original directory. */ GetCurrentDirectory(NULL, szOriginalDirectory); GetWindowsDirectory(szWindowsDirectory, MAXITEMPATHLEN+1);#ifdef DEBUG ShowWindow(ghwndMain, SW_MINIMIZE); // // If this is the shared WOW, change the app title string to // reflect this and change the window title. ////.........这里部分代码省略.........
开发者ID:chunhualiu,项目名称:OpenNT,代码行数:101,
示例6: WinMainint WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wcex; HMENU menu, popupMenu; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); wcex.hCursor = LoadCursor(hInstance, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wcex.lpszMenuName = NULL; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); if (!RegisterClassEx(&wcex)) { MessageBox(NULL, _T("Call to RegisterClassEx failed!"), _T("Win32 Guided Tour"), NULL); return 1; } hInst = hInstance; // Store instance handle in our global variable // The parameters to CreateWindow explained: // szWindowClass: the name of the application // szTitle: the text that appears in the title bar // WS_SYSMENU: the type of window to create // CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y) // 500, 100: initial size (width, length) // NULL: the parent of this window // TODO: // NULL: this application does not have a menu bar // hInstance: the first parameter from WinMain // NULL: not used in this application hWnd = CreateWindow( szWindowClass, szTitle, WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, WindowWidth, WindowHeight, NULL, NULL, hInstance, NULL ); if (!hWnd) { MessageBox(NULL, _T("Call to CreateWindow failed!"), _T("Win32 Guided Tour"), NULL); return 1; } hButtonRefresh = CreateWindow(L"button", NULL, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 0, 0, 32, 32, hWnd, (HMENU)IDC_BUTTON_REFRESH, hInst, NULL); hButtonClear = CreateWindow(L"button", NULL, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 0, 32, 32, 32, hWnd, (HMENU)IDC_BUTTON_CLEAR, hInst, NULL); // The parameters to ShowWindow explained: // hWnd: the value returned from CreateWindow // nCmdShow: the fourth parameter from WinMain ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // Main message loop: MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int)msg.wParam;}
开发者ID:chiselko6,项目名称:SP,代码行数:83,
|