static BOOL InitListViewImageLists(HWND hwndLV) { HIMAGELIST himl; /* handle to image list */ HICON hico; /* handle to icon */ /* Create the image list. */ if ((himl = ImageList_Create(CX_ICON, CY_ICON, ILC_MASK, 0, NUM_ICONS)) == NULL) { return FALSE; } hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_BIN)); Image_Bin = ImageList_AddIcon(himl, hico); hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_STRING)); Image_String = ImageList_AddIcon(himl, hico); /* Fail if not all of the images were added. */ if (ImageList_GetImageCount(himl) < NUM_ICONS) { return FALSE; } /* Associate the image list with the tree view control. */ (void)ListView_SetImageList(hwndLV, himl, LVSIL_SMALL); return TRUE; }
/* * InitTreeViewImageLists - creates an image list, adds three bitmaps * to it, and associates the image list with a tree view control. * Returns TRUE if successful, or FALSE otherwise. * hwndTV - handle to the tree view control. */ static BOOL InitTreeViewImageLists(HWND hwndTV) { HIMAGELIST himl; /* handle to image list */ HICON hico; /* handle to icon */ /* Create the image list. */ if ((himl = ImageList_Create(CX_ICON, CY_ICON, ILC_MASK, 0, NUM_ICONS)) == NULL) return FALSE; /* Add the open file, closed file, and document bitmaps. */ hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_OPEN_FILE)); Image_Open = ImageList_AddIcon(himl, hico); hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_CLOSED_FILE)); Image_Closed = ImageList_AddIcon(himl, hico); hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_ROOT)); Image_Root = ImageList_AddIcon(himl, hico); /* Fail if not all of the images were added. */ if (ImageList_GetImageCount(himl) < NUM_ICONS) { return FALSE; } /* Associate the image list with the tree view control. */ SendMessageW(hwndTV, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)himl); return TRUE; }
// Registers the GLFW window class // GLboolean _glfwRegisterWindowClass(void) { WNDCLASSW wc; wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = (WNDPROC) windowProc; wc.cbClsExtra = 0; // No extra class data wc.cbWndExtra = sizeof(void*) + sizeof(int); // Make room for one pointer wc.hInstance = GetModuleHandleW(NULL); wc.hCursor = LoadCursorW(NULL, IDC_ARROW); wc.hbrBackground = NULL; // No background wc.lpszMenuName = NULL; // No menu wc.lpszClassName = _GLFW_WNDCLASSNAME; // Load user-provided icon if available wc.hIcon = LoadIconW(GetModuleHandleW(NULL), L"GLFW_ICON"); if (!wc.hIcon) { // No user-provided icon found, load default icon wc.hIcon = LoadIconW(NULL, IDI_WINLOGO); } if (!RegisterClassW(&wc)) { _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to register window class"); return GL_FALSE; } return GL_TRUE; }
/*-------------------------------------- * Function: registerWindowClass() *------------------------------------*/ static void registerWindowClass(void) { WNDCLASSEXW wcx = { 0 }; wchar_t* class_name = wstrdup(ClassName); wcx.cbSize = sizeof(WNDCLASSEXW); wcx.style = CS_HREDRAW | CS_VREDRAW; wcx.lpfnWndProc = WindowProc; wcx.cbClsExtra = 0; wcx.cbWndExtra = 0; wcx.hInstance = GetModuleHandleW(NULL); wcx.hIcon = LoadIconW(NULL, IDI_APPLICATION); wcx.hCursor = LoadCursorW(NULL, IDC_ARROW); wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcx.lpszMenuName = NULL; wcx.lpszClassName = class_name; wcx.hIconSm = NULL; if (!RegisterClassExW(&wcx)) { free(class_name); error("could not register window class"); } free(class_name); }
int main(int argc, char *argv[]) { WNDCLASSW wc; MSG msg; ZeroMemory(&wc, sizeof (WNDCLASSW)); wc.lpszClassName = L"mainwin"; wc.lpfnWndProc = wndProc; wc.hInstance = GetModuleHandle(NULL); wc.hIcon = LoadIconW(NULL, IDI_APPLICATION); wc.hCursor = LoadCursorW(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); RegisterClassW(&wc); mainwin = CreateWindowExW(0, L"mainwin", L"mainwin", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 400, 400, NULL, NULL, GetModuleHandle(NULL), NULL); if (argc > 1) dialog = CreateWindowExW(WS_EX_CONTROLPARENT, WC_DIALOG, L"", WS_CHILD | WS_VISIBLE, 100, 100, 200, 200, mainwin, NULL, GetModuleHandle(NULL), NULL); else { const BYTE dlgtemplate[] = { 0x01, 0x00, // version 0xFF, 0xFF, // signature 0x00, 0x00, 0x00, 0x00, // help 0x00, 0x00, 0x01, 0x00, // WS_EX_CONTROLPARENT 0x00, 0x00, 0x00, 0x50, // WS_CHILD | WS_VISIBLE 0x00, 0x00, // no controls 100, 0, // X/Y/Width/Height 100, 0, 100, 0, 100, 0, 0x00, 0x00, // menu 0x00, 0x00, // class 0x00, 0x00, // title 0x00, 0x00, 0x00, 0x00, // some padding 0x00, 0x00, 0x00, 0x00, // more padding 0x00, 0x00, 0x00, 0x00, // just to be safe }; dialog = CreateDialogIndirectW(GetModuleHandle(NULL), (LPCDLGTEMPLATEW) dlgtemplate, mainwin, dlgproc); } printf("%I32X\n", EnableThemeDialogTexture(dialog, ETDT_ENABLE | ETDT_USETABTEXTURE | ETDT_ENABLETAB)); ShowWindow(mainwin, SW_SHOWDEFAULT); UpdateWindow(mainwin); while (GetMessageW(&msg, NULL, 0, 0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; }
static BOOL WINAPI register_classes( INIT_ONCE *once, void *param, void **context ) { WNDCLASSW wndClass; ZeroMemory(&wndClass, sizeof(WNDCLASSW)); wndClass.style = CS_GLOBALCLASS | CS_IME | CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = IME_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 2 * sizeof(LONG_PTR); wndClass.hInstance = x11drv_module; wndClass.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW); wndClass.hIcon = LoadIconW(NULL, (LPWSTR)IDI_APPLICATION); wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW +1); wndClass.lpszMenuName = 0; wndClass.lpszClassName = UI_CLASS_NAME; RegisterClassW(&wndClass); WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService"); WM_MSIME_RECONVERTOPTIONS = RegisterWindowMessageA("MSIMEReconvertOptions"); WM_MSIME_MOUSE = RegisterWindowMessageA("MSIMEMouseOperation"); WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageA("MSIMEReconvertRequest"); WM_MSIME_RECONVERT = RegisterWindowMessageA("MSIMEReconvert"); WM_MSIME_QUERYPOSITION = RegisterWindowMessageA("MSIMEQueryPosition"); WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed"); return TRUE; }
void Window::Register() try { HINSTANCE instanceHandle = GetModuleHandleW(nullptr); WNDCLASSEXW windowClass; ZeroMemory(&windowClass, sizeof(windowClass)); windowClass.cbSize = sizeof(WNDCLASSEXW); windowClass.style = CS_OWNDC; windowClass.lpfnWndProc = WindowHandleMessage; windowClass.hInstance = instanceHandle; windowClass.hIcon = LoadIconW(instanceHandle, MAKEINTRESOURCEW(IDI_ICON1)); windowClass.hCursor = LoadCursorW(nullptr, MAKEINTRESOURCEW(IDI_APPLICATION)); windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); windowClass.lpszMenuName = nullptr; windowClass.lpszClassName = CLASS_NAME; if (!RegisterClassExW(&windowClass)) { throw std::runtime_error("Registration of Window failed"); } wasRegistered = true; } catch (std::runtime_error error) { MessageBoxA(0, error.what(), "Error!", MB_ICONEXCLAMATION | MB_OK); PostQuitMessage(-1); }
/* First Applet */ static LONG CALLBACK SystemApplet(VOID) { PROPSHEETPAGEW page[2]; PROPSHEETHEADERW header; WCHAR szCaption[MAX_STR_LEN]; LoadStringW(hApplet, IDS_CPLSYSTEMNAME, szCaption, ARRAYSIZE(szCaption)); ZeroMemory(&header, sizeof(header)); header.dwSize = sizeof(header); header.dwFlags = PSH_PROPSHEETPAGE; header.hwndParent = hCPLWindow; header.hInstance = hApplet; header.hIcon = LoadIconW(hApplet, MAKEINTRESOURCEW(IDI_CPLSYSTEM)); header.pszCaption = szCaption; header.nPages = ARRAYSIZE(page); header.nStartPage = 0; header.ppsp = page; header.pfnCallback = NULL; /* Settings */ InitPropSheetPage(&page[0], IDD_PROPPAGESETTINGS, SettingsPageProc); /* Advanced Settings */ InitPropSheetPage(&page[1], IDD_PROPPAGEADVANCEDSETTINGS, AdvancedSettingsPageProc); return (LONG)(PropertySheetW(&header) != -1); }
/************************************************************************* * ExtractAssociatedIconW (SHELL32.@) * * Return icon for given file (either from file itself or from associated * executable) and patch parameters if needed. */ HICON WINAPI ExtractAssociatedIconW(HINSTANCE hInst, LPWSTR lpIconPath, LPWORD lpiIcon) { HICON hIcon = NULL; WORD wDummyIcon = 0; TRACE("%p %s %p\n", hInst, debugstr_w(lpIconPath), lpiIcon); if(lpiIcon == NULL) lpiIcon = &wDummyIcon; hIcon = ExtractIconW(hInst, lpIconPath, *lpiIcon); if( hIcon < (HICON)2 ) { if( hIcon == (HICON)1 ) /* no icons found in given file */ { WCHAR tempPath[MAX_PATH]; HINSTANCE uRet = FindExecutableW(lpIconPath,NULL,tempPath); if( uRet > (HINSTANCE)32 && tempPath[0] ) { lstrcpyW(lpIconPath,tempPath); hIcon = ExtractIconW(hInst, lpIconPath, *lpiIcon); if( hIcon > (HICON)2 ) return hIcon; } } if( hIcon == (HICON)1 ) *lpiIcon = 2; /* MSDOS icon - we found .exe but no icons in it */ else *lpiIcon = 6; /* generic icon - found nothing */ if (GetModuleFileNameW(hInst, lpIconPath, MAX_PATH)) hIcon = LoadIconW(hInst, MAKEINTRESOURCEW(*lpiIcon)); } return hIcon; }
/************************************************************************* * ShellAboutW [SHELL32.289] */ BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon ) { ABOUT_INFO info; HRSRC hRes; DLGTEMPLATE *DlgTemplate; BOOL bRet; TRACE("\n"); // DialogBoxIndirectParamW will be called with the hInstance of the calling application, so we have to preload the dialog template hRes = FindResourceW(shell32_hInstance, MAKEINTRESOURCEW(IDD_ABOUT), (LPWSTR)RT_DIALOG); if(!hRes) return FALSE; DlgTemplate = (DLGTEMPLATE *)LoadResource(shell32_hInstance, hRes); if(!DlgTemplate) return FALSE; info.szApp = szApp; info.szOtherStuff = szOtherStuff; info.hIcon = hIcon ? hIcon : LoadIconW( 0, (LPWSTR)IDI_WINLOGO ); bRet = DialogBoxIndirectParamW((HINSTANCE)GetWindowLongPtrW( hWnd, GWLP_HINSTANCE ), DlgTemplate, hWnd, AboutDlgProc, (LPARAM)&info ); return bRet; }
BOOL CALLBACK EnumPickIconResourceProc(HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam ) { WCHAR szName[100]; int index; HICON hIcon; PPICK_ICON_CONTEXT pIconContext = (PPICK_ICON_CONTEXT)lParam; if (IS_INTRESOURCE(lpszName)) swprintf(szName, L"%u", lpszName); else wcscpy(szName, (WCHAR*)lpszName); hIcon = LoadIconW(pIconContext->hLibrary, (LPCWSTR)lpszName); if (hIcon == NULL) return TRUE; index = SendMessageW(pIconContext->hDlgCtrl, LB_ADDSTRING, 0, (LPARAM)szName); if (index != LB_ERR) SendMessageW(pIconContext->hDlgCtrl, LB_SETITEMDATA, index, (LPARAM)hIcon); return TRUE; }
BOOL CMainWindow::AddTrayIcon(void) { NOTIFYICONDATAW nid; HICON hIcon = NULL; WCHAR szTip[128]; BOOL bRetVal; ZeroMemory(&nid, sizeof(NOTIFYICONDATAW)); hIcon = LoadIconW(g_hInstance, MAKEINTRESOURCEW(IDI_DISPLAYSLEEP)); nid.cbSize = sizeof(NOTIFYICONDATAW); nid.hWnd = m_hMainWnd; nid.uID = 0; nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nid.uCallbackMessage = WM_ONTRAYICON; nid.hIcon = hIcon; LoadStringW(g_hInstance, IDS_TRAYTIP, szTip, 64); wcscpy_s(nid.szTip, 128, szTip); bRetVal = Shell_NotifyIconW(NIM_ADD, &nid); if (hIcon) DestroyIcon(hIcon); return bRetVal; }
/* * Message Action Function */ LRESULT MainWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandle) { auto hr = Initialize(); if (hr != S_OK) { ::MessageBoxW(nullptr, L"Initialize() failed", L"Fatal error", MB_OK | MB_ICONSTOP); std::terminate(); return S_FALSE; } HICON hIcon = LoadIconW(GetModuleHandleW(nullptr), MAKEINTRESOURCEW(IDI_CLANGBUILDERUI)); SetIcon(hIcon, TRUE); HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); LOGFONTW logFont = { 0 }; GetObjectW(hFont, sizeof(logFont), &logFont); DeleteObject(hFont); hFont = NULL; logFont.lfHeight = 19; logFont.lfWeight = FW_NORMAL; wcscpy_s(logFont.lfFaceName, L"Segoe UI"); hFont = CreateFontIndirectW(&logFont); auto LambdaCreateWindow = [&](LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HMENU hMenu)->HWND{ auto hw = CreateWindowExW(WINDOWEXSTYLE, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, m_hWnd, hMenu, HINST_THISCOMPONENT, nullptr); if (hw) { ::SendMessageW(hw, WM_SETFONT, (WPARAM)hFont, lParam); } return hw; }; hCobVS_ = LambdaCreateWindow(WC_COMBOBOXW, L"", COMBOBOXSTYLE, 200, 20, 400, 30, nullptr); hCobArch_ = LambdaCreateWindow(WC_COMBOBOXW, L"", COMBOBOXSTYLE, 200, 60, 400, 30, nullptr); hCobFlavor_ = LambdaCreateWindow(WC_COMBOBOXW, L"", COMBOBOXSTYLE, 200, 100, 400, 30, nullptr); hCheckBoostrap_ = LambdaCreateWindow(WC_BUTTONW, L"Clang Boostrap", CHECKBOXSTYLE, 200, 160, 360, 27, nullptr); hCheckReleased_ = LambdaCreateWindow(WC_BUTTONW, L"Released Revision", CHECKBOXSTYLE, 200, 190, 360, 27, nullptr); hCheckPackaged_ = LambdaCreateWindow(WC_BUTTONW, L"Make installation package", CHECKBOXSTYLE, 200, 220, 360, 27, nullptr); hCheckCleanEnv_ = LambdaCreateWindow(WC_BUTTONW, L"Use Clean Environment", CHECKBOXSTYLE, 200, 250, 360, 27, nullptr); hCheckLink_ = LambdaCreateWindow(WC_BUTTONW, L"Link Static Runtime Library", CHECKBOXSTYLE, 200, 280, 360, 27, nullptr); hCheckNMake_ = LambdaCreateWindow(WC_BUTTONW, L"Use NMake Makefiles", CHECKBOXSTYLE, 200, 310, 360, 27, nullptr); hCheckLLDB_ = LambdaCreateWindow(WC_BUTTONW, L"Build LLDB (Visual Studio 2015 or Later)", CHECKBOXSTYLE, 200, 340, 360, 27, nullptr); //Button_SetElevationRequiredState hButtonTask_ = LambdaCreateWindow(WC_BUTTONW, L"Build Now", PUSHBUTTONSTYLE, 200, 395, 195, 30, (HMENU)IDC_BUTTON_STARTTASK); hButtonEnv_ = LambdaCreateWindow(WC_BUTTONW, L"Startup Env", PUSHBUTTONSTYLE | BS_ICON, 410, 395, 195, 30, (HMENU)IDC_BUTTON_STARTENV); HMENU hSystemMenu = ::GetSystemMenu(m_hWnd, FALSE); InsertMenuW(hSystemMenu, SC_CLOSE, MF_ENABLED, IDM_CLANGBUILDER_ABOUT, L"About ClangbuilderUI\tAlt+F1"); label_.push_back(KryceLabel(30, 20, 190, 50, L"Visual Studio\t\xD83C\xDD9A:")); label_.push_back(KryceLabel(30, 60, 190, 90, L"Address Mode\t\xD83D\xDEE0:")); label_.push_back(KryceLabel(30, 100, 190, 130, L"Configuration\t\x2699:")); label_.push_back(KryceLabel(30, 160, 190, 200, L"Compile Switch\t\xD83D\xDCE6:")); /// if (!InitializeControl()) { } //DeleteObject(hFont); return S_OK; }
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) { HICON hIcon; WCHAR szText[260]; BOOL bLargeIcon; BOOL bHung = FALSE; typedef int (FAR __stdcall *IsHungAppWindowProc)(HWND); IsHungAppWindowProc IsHungAppWindow; /* Skip our window */ if (hWnd == hMainWnd) return TRUE; bLargeIcon = (TaskManagerSettings.ViewMode == ID_VIEW_LARGE); GetWindowTextW(hWnd, szText, 260); /* Get the window text */ /* Check and see if this is a top-level app window */ if ((wcslen(szText) <= 0) || !IsWindowVisible(hWnd) || (GetParent(hWnd) != NULL) || (GetWindow(hWnd, GW_OWNER) != NULL) || (GetWindowLongPtrW(hWnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)) { return TRUE; /* Skip this window */ } noApps = FALSE; /* Get the icon for this window */ hIcon = NULL; SendMessageTimeoutW(hWnd, WM_GETICON, bLargeIcon ? ICON_BIG : ICON_SMALL, 0, 0, 1000, (PDWORD_PTR)&hIcon); if (!hIcon) { /* We failed, try to retrieve other icons... */ hIcon = (HICON)(LONG_PTR)GetClassLongPtrW(hWnd, bLargeIcon ? GCL_HICON : GCL_HICONSM); if (!hIcon) hIcon = (HICON)(LONG_PTR)GetClassLongPtrW(hWnd, bLargeIcon ? GCL_HICONSM : GCL_HICON); if (!hIcon) SendMessageTimeoutW(hWnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (PDWORD_PTR)&hIcon); if (!hIcon) SendMessageTimeoutW(hWnd, WM_GETICON, bLargeIcon ? ICON_SMALL : ICON_BIG, 0, 0, 1000, (PDWORD_PTR)&hIcon); /* If we still do not have any icon, load the default one */ if (!hIcon) hIcon = LoadIconW(hInst, bLargeIcon ? MAKEINTRESOURCEW(IDI_WINDOW) : MAKEINTRESOURCEW(IDI_WINDOWSM)); } bHung = FALSE; IsHungAppWindow = (IsHungAppWindowProc)(FARPROC)GetProcAddress(GetModuleHandleW(L"USER32.DLL"), "IsHungAppWindow"); if (IsHungAppWindow) bHung = IsHungAppWindow(hWnd); AddOrUpdateHwnd(hWnd, szText, hIcon, bHung); return TRUE; }
static void HH_RegisterChildWndClass(HHInfo *pHHInfo) { WNDCLASSEXW wcex; wcex.cbSize = sizeof(WNDCLASSEXW); wcex.style = 0; wcex.lpfnWndProc = Child_WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hhctrl_hinstance; wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION); wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); wcex.lpszMenuName = NULL; wcex.lpszClassName = szChildClass; wcex.hIconSm = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION); RegisterClassExW(&wcex); }
static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { WCHAR empty = 0; WNDCLASSEXW wndclass = {0}; /* Frame class */ wndclass.cbSize = sizeof(WNDCLASSEXW); wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = FrameWndProc; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT)); wndclass.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW); wndclass.lpszClassName = szFrameClass; wndclass.hIconSm = LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); RegisterClassExW(&wndclass); /* Child class */ wndclass.lpfnWndProc = ChildWndProc; wndclass.cbWndExtra = sizeof(HANDLE); wndclass.lpszClassName = szChildClass; RegisterClassExW(&wndclass); hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU)); hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS)); /* Initialize the Windows Common Controls DLL */ InitCommonControls(); /* register our hex editor control */ HexEdit_Register(); nClipboardFormat = RegisterClipboardFormatW(strClipboardFormat); hFrameWnd = CreateWindowExW(0, szFrameClass, szTitle, WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, hMenuFrame, hInstance, NULL/*lpParam*/); if (!hFrameWnd) { return FALSE; } /* Create the status bar */ hStatusBar = CreateStatusWindowW(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, &empty, hFrameWnd, STATUS_WINDOW); if (hStatusBar) { /* Create the status bar panes */ SetupStatusBar(hFrameWnd, FALSE); CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED); } ShowWindow(hFrameWnd, nCmdShow); UpdateWindow(hFrameWnd); return TRUE; }
/*********************************************************************** * DrawInsert (COMCTL32.15) * * Draws insert arrow by the side of the ListBox item in the parent window. * * RETURNS * Nothing. */ VOID WINAPI DrawInsert (HWND hwndParent, HWND hwndLB, INT nItem) { RECT rcItem, rcListBox, rcDragIcon; HDC hdc; DRAGLISTDATA * data; TRACE("(%p %p %d)\n", hwndParent, hwndLB, nItem); if (!hDragArrow) hDragArrow = LoadIconW(COMCTL32_hModule, (LPCWSTR)IDI_DRAGARROW); if (LB_ERR == SendMessageW(hwndLB, LB_GETITEMRECT, nItem, (LPARAM)&rcItem)) return; if (!GetWindowRect(hwndLB, &rcListBox)) return; /* convert item rect to parent co-ordinates */ if (!MapWindowPoints(hwndLB, hwndParent, (LPPOINT)&rcItem, 2)) return; /* convert list box rect to parent co-ordinates */ if (!MapWindowPoints(HWND_DESKTOP, hwndParent, (LPPOINT)&rcListBox, 2)) return; rcDragIcon.left = rcListBox.left - DRAGICON_HOTSPOT_X; rcDragIcon.top = rcItem.top - DRAGICON_HOTSPOT_Y; rcDragIcon.right = rcListBox.left; rcDragIcon.bottom = rcDragIcon.top + DRAGICON_HEIGHT; if (!GetWindowSubclass(hwndLB, DragList_SubclassWindowProc, DRAGLIST_SUBCLASSID, (DWORD_PTR*)&data)) return; if (nItem < 0) SetRectEmpty(&rcDragIcon); /* prevent flicker by only redrawing when necessary */ if (!EqualRect(&rcDragIcon, &data->last_drag_icon_rect)) { /* get rid of any previous inserts drawn */ RedrawWindow(hwndParent, &data->last_drag_icon_rect, NULL, RDW_INTERNALPAINT | RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW); CopyRect(&data->last_drag_icon_rect, &rcDragIcon); if (nItem >= 0) { hdc = GetDC(hwndParent); DrawIcon(hdc, rcDragIcon.left, rcDragIcon.top, hDragArrow); ReleaseDC(hwndParent, hdc); } } }
ATOM UGameWindow::RegisterWindowClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(107)); wcex.hIconSm = LoadIconW(hInstance, MAKEINTRESOURCEW(107)); wcex.hCursor = LoadCursorW(nullptr, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wcex.lpszClassName = UGameWindow::szWindowClass; wcex.lpszMenuName = 0; return RegisterClassExW(&wcex); }
ATOM UGameWindow::RegisterWindowClass(HINSTANCE inHInstance, const wchar_t* inWindowClassName) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = inHInstance; wcex.hIcon = LoadIconW(nullptr, IDI_APPLICATION); wcex.hIconSm = LoadIconW(nullptr, IDI_APPLICATION); wcex.hCursor = LoadCursorW(nullptr, IDC_ARROW); wcex.hbrBackground = nullptr; wcex.lpszClassName = inWindowClassName; wcex.lpszMenuName = nullptr; return RegisterClassExW(&wcex); }
static void hugsprim_LoadIconW_2(HugsStackPtr hugs_root) { HsPtr arg1; HsPtr arg2; HsPtr res1; arg1 = hugs->getPtr(); arg2 = hugs->getPtr(); res1 = LoadIconW(arg1, arg2); hugs->putPtr(res1); hugs->returnIO(hugs_root,1); }
HICON AP_Win32App::getSmallIcon(void) { int sy = GetSystemMetrics(SM_CYICON); int sx = GetSystemMetrics(SM_CXICON); UT_DEBUGMSG(("GetIcon(): system metrics [%d %d]\n",sx,sy)); if ((sx==16) && (sy==16)) return LoadIconW(getInstance(), MAKEINTRESOURCEW(AP_RID_ICON_APPLICATION_16)); else return (HICON) LoadImageW(getInstance(), MAKEINTRESOURCEW(AP_RID_ICON_APPLICATION_16), IMAGE_ICON, 0,0,0); }
/****************************************************************************** * propsheet_callback [internal] * */ static int CALLBACK propsheet_callback(HWND hwnd, UINT msg, LPARAM lparam) { TRACE("(%p, 0x%08x/%d, 0x%lx)\n", hwnd, msg, msg, lparam); switch (msg) { case PSCB_INITIALIZED: SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM) LoadIconW(hcpl, MAKEINTRESOURCEW(ICO_MAIN))); break; } return 0; }
ATOM RegisterWinClass(const wchar_t* pszName, WNDPROC proc, HINSTANCE hInst, UINT menuID, UINT iconID, UINT smallIconID) { WNDCLASSEXW wc = {}; wc.cbSize = sizeof(wc); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = proc; wc.lpszClassName = pszName; wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hInstance = hInst; wc.lpszMenuName = MAKEINTRESOURCEW(menuID); wc.hIcon = LoadIconW(hInst, MAKEINTRESOURCEW(iconID)); wc.hIconSm = LoadIconW(hInst, MAKEINTRESOURCEW(smallIconID)); return RegisterClassExW(&wc); }
static BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) { HICON hIcon; WCHAR wszText[256]; BOOL bLargeIcon; BOOL bHung = FALSE; typedef int (__stdcall *IsHungAppWindowProc)(HWND); IsHungAppWindowProc IsHungAppWindow; /* Skip our window */ if (hWnd == hMainWnd) return TRUE; bLargeIcon = TaskManagerSettings.View_LargeIcons ? TRUE : FALSE; /* Check and see if this is a top-level app window */ if (!GetWindowTextW(hWnd, wszText, sizeof(wszText)/sizeof(WCHAR)) || !IsWindowVisible(hWnd) || (GetParent(hWnd) != NULL) || (GetWindow(hWnd, GW_OWNER) != NULL) || (GetWindowLongW(hWnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)) { return TRUE; /* Skip this window */ } /* Get the icon for this window */ hIcon = NULL; SendMessageTimeoutW(hWnd, WM_GETICON, bLargeIcon ? ICON_BIG /*1*/ : ICON_SMALL /*0*/, 0, 0, 1000, (PDWORD_PTR)&hIcon); if (!hIcon) { hIcon = (HICON)GetClassLongPtrW(hWnd, bLargeIcon ? GCLP_HICON : GCLP_HICONSM); if (!hIcon) hIcon = (HICON)GetClassLongPtrW(hWnd, bLargeIcon ? GCLP_HICONSM : GCLP_HICON); if (!hIcon) SendMessageTimeoutW(hWnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (PDWORD_PTR)&hIcon); if (!hIcon) SendMessageTimeoutW(hWnd, WM_GETICON, bLargeIcon ? ICON_SMALL /*0*/ : ICON_BIG /*1*/, 0, 0, 1000, (PDWORD_PTR)&hIcon); } if (!hIcon) hIcon = LoadIconW(hInst, bLargeIcon ? MAKEINTRESOURCEW(IDI_WINDOW) : MAKEINTRESOURCEW(IDI_WINDOWSM)); bHung = FALSE; IsHungAppWindow = (IsHungAppWindowProc)(FARPROC)GetProcAddress(GetModuleHandleW(wszUser32), "IsHungAppWindow"); if (IsHungAppWindow) bHung = IsHungAppWindow(hWnd); AddOrUpdateHwnd(hWnd, wszText, hIcon, bHung); return TRUE; }
/// <summary> /// Creates the main window and begins processing /// </summary> /// <param name="hInstance">handle to the application instance</param> /// <param name="nCmdShow">whether to display minimized, maximized, or normally</param> int CFaceBasics::Run(HINSTANCE hInstance, int nCmdShow) { MSG msg = {0}; WNDCLASS wc; // Dialog custom window class ZeroMemory(&wc, sizeof(wc)); wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbWndExtra = DLGWINDOWEXTRA; wc.hCursor = LoadCursorW(NULL, IDC_ARROW); wc.hIcon = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APP)); wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); wc.lpfnWndProc = DefDlgProcW; wc.lpszClassName = L"Face-And-HDFace-Basics-D2DAppDlgWndClass"; if (!RegisterClassW(&wc)) { return 0; } //hMenu = LoadMenuW(hInstance, MAKEINTRESOURCE(IDR_MENU1)); // Create main application window HWND hWndApp = CreateDialogParamW( NULL, MAKEINTRESOURCE(IDD_APP), NULL, (DLGPROC)CFaceBasics::MessageRouter, reinterpret_cast<LPARAM>(this)); //HWND hWndApp = CreateDialogParamW( NULL, MAKEINTRESOURCE(IDD_APP), NULL, (DLGPROC)CFaceBasics::MessageRouter, WS_CAPTION); // Show window ShowWindow(hWndApp, nCmdShow); //ShowWindow(hWndApp, 3); // Main message loop while (WM_QUIT != msg.message) { Update(); while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { // If a dialog message will be taken care of by the dialog proc if (hWndApp && IsDialogMessageW(hWndApp, &msg)) { continue; } TranslateMessage(&msg); DispatchMessageW(&msg); } } return static_cast<int>(msg.wParam); }
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) { HICON hIcon; WCHAR szText[260]; BOOL bHung = FALSE; HICON* xhIcon = (HICON*)&hIcon; typedef int (FAR __stdcall *IsHungAppWindowProc)(HWND); IsHungAppWindowProc IsHungAppWindow; /* Skip our window */ if (hWnd == CurrenthWnd) return TRUE; GetWindowTextW(hWnd, szText, 260); /* Get the window text */ /* Check and see if this is a top-level app window */ if ((wcslen(szText) <= 0) || !IsWindowVisible(hWnd) || (GetParent(hWnd) != NULL) || (GetWindow(hWnd, GW_OWNER) != NULL) || (GetWindowLongPtrW(hWnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)) { return TRUE; /* Skip this window */ } /* Get the icon for this window */ hIcon = NULL; SendMessageTimeoutW(hWnd, WM_GETICON, ICON_SMALL, 0, 0, 1000, (PDWORD_PTR)xhIcon); if (!hIcon) { hIcon = (HICON)(LONG_PTR)GetClassLongPtrW(hWnd, GCL_HICONSM); if (!hIcon) hIcon = (HICON)(LONG_PTR)GetClassLongPtrW(hWnd, GCL_HICON); if (!hIcon) SendMessageTimeoutW(hWnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (PDWORD_PTR)xhIcon); } if (!hIcon) hIcon = LoadIconW(NULL, MAKEINTRESOURCEW(IDI_APPLICATION)); bHung = FALSE; IsHungAppWindow = (IsHungAppWindowProc)(FARPROC)GetProcAddress(GetModuleHandleW(L"USER32.DLL"), "IsHungAppWindow"); if (IsHungAppWindow) bHung = IsHungAppWindow(hWnd); AddOrUpdateHwnd(hWnd, szText, hIcon, bHung); return TRUE; }
BOOL CMainWindow::Initialize(LPCTSTR lpCaption, int nCmdShow) { WNDCLASSEXW wc = {0}; /* Store the show window value */ m_CmdShow = nCmdShow; /* Setup the window class struct */ wc.cbSize = sizeof(WNDCLASSEXW); wc.lpfnWndProc = MainWndProc; wc.hInstance = g_hInstance; wc.hIcon = LoadIconW(g_hInstance, MAKEINTRESOURCEW(IDI_DISPLAYSLEEP)); wc.hCursor = LoadCursorW(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); wc.lpszMenuName = NULL; wc.lpszClassName = m_szMainWndClass; wc.hIconSm = (HICON)LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_DISPLAYSLEEP), IMAGE_ICON, 16, 16, LR_SHARED); /* Register the window */ if (RegisterClassExW(&wc)) { /* Create the main window and store the info pointer */ m_hMainWnd = CreateWindowExW(WS_EX_WINDOWEDGE, m_szMainWndClass, lpCaption, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CW_USEDEFAULT, CW_USEDEFAULT, 600, 450, NULL, NULL, g_hInstance, this); if (m_hMainWnd) { ShowWindow(m_hMainWnd, SW_NORMAL); } } /* Return creation result */ return !!(m_hMainWnd); }
static INT_PTR CALLBACK DownloadDlgProc(HWND Dlg, UINT Msg, WPARAM wParam, LPARAM lParam) { HANDLE Thread; DWORD ThreadId; HWND Item; switch (Msg) { case WM_INITDIALOG: hIcon = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN)); if (hIcon) { SendMessageW(Dlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon); SendMessageW(Dlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon); } SetWindowLongPtrW(Dlg, GWLP_USERDATA, 0); Item = GetDlgItem(Dlg, IDC_DOWNLOAD_PROGRESS); if (Item) { SendMessageW(Item, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); SendMessageW(Item, PBM_SETPOS, 0, 0); } Thread = CreateThread(NULL, 0, ThreadFunc, Dlg, 0, &ThreadId); if (!Thread) return FALSE; CloseHandle(Thread); return TRUE; case WM_COMMAND: if (wParam == IDCANCEL) { SetWindowLongPtrW(Dlg, GWLP_USERDATA, 1); PostMessageW(Dlg, WM_CLOSE, 0, 0); } return FALSE; case WM_CLOSE: if (hIcon) DestroyIcon(hIcon); EndDialog(Dlg, 0); return TRUE; default: return FALSE; } }
static bool wndRegisterClass(HINSTANCE theInstance, const StStringUtfWide& theClassName) { WNDCLASSW aClass; aClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; aClass.lpfnWndProc = (WNDPROC )wndProcWrapper; aClass.cbClsExtra = 0; aClass.cbWndExtra = 0; aClass.hInstance = theInstance; aClass.hIcon = LoadIconW(theInstance, L"A"); aClass.hCursor = LoadCursor(NULL, IDC_ARROW); aClass.hbrBackground = NULL; aClass.lpszMenuName = NULL; aClass.lpszClassName = theClassName.toCString(); return (RegisterClassW(&aClass) != 0); }
void makeTableWindowClass(void) { WNDCLASSW wc; ZeroMemory(&wc, sizeof (WNDCLASSW)); wc.lpszClassName = tableWindowClass; wc.lpfnWndProc = tableWndProc; wc.hCursor = LoadCursorW(NULL, IDC_ARROW); wc.hIcon = LoadIconW(NULL, IDI_APPLICATION); wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); // TODO correct? wc.style = CS_HREDRAW | CS_VREDRAW; wc.hInstance = GetModuleHandle(NULL); if (RegisterClassW(&wc) == 0) abort(); }