Can somebody please send me a .cpp file which show's how to use icons on the windows? I've got a tutorial but I cannot figure it out because it's in C, not C++.
Thanks
Can somebody please send me a .cpp file which show's how to use icons on the windows? I've got a tutorial but I cannot figure it out because it's in C, not C++.
Thanks
It should be jut the same. C++ is simply C with a few extras
Yea, but can you send me an example please?
what does signature stand for?
It's not that hard. All you need to do is go into FILE->ADD->RESOURCE. Create a resource file this way. Then right click on the resource and choose ADD, then select icon. This will bring up a 32x32 icon pic which you can change to what you want. Make the id whatever(I will use IDI_ICON), then when you initialize your windows class do:
hInstance is the handle to your window class(because the icon is stored in the exe).Code:wndclass.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON));
MAKEINTRESOURCE is a macro that will convert the resource id into the appropriate data value.
If it isnt that hard, can you send me an example please?
Thanks
what does signature stand for?
Code:LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { static TCHAR szAppName[] = TEXT("My App") ; HWND hwnd ; MSG msg ; WNDCLASS wndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TITLE)); wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); wndclass.lpszMenuName = NULL ; wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass)) { MessageBox (NULL, "An Error occoured in Registering the Window Class", szAppName, MB_ICONERROR) ; return 0 ; } TCHAR *pszBuffer = new TCHAR[256]; LoadString(hInstance, IDS_TITLEBAR, pszBuffer, 256); hwnd = CreateWindow( szAppName, pszBuffer, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, GetSystemMetrics(SM_CXSCREEN) * 3 / 4, GetSystemMetrics(SM_CYSCREEN) * 3 / 4, NULL, NULL, hInstance, NULL ); ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); delete[] pszBuffer; while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } return msg.wParam; }
Err, a lotsa people told me that but, can you send it as a complete cpp file with the resources etc? Cuz I always get an error..
Thanks
what does signature stand for?
here:
Thanks Treveller!
what does signature stand for?