#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "resources.h"
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_CREATE:
{
return(0);
} break;
case WM_PAINT:
{
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
return(0);
} break;
case WM_DESTROY:
{
PostQuitMessage(0);
return(0);
} break;
default:break;
}
return(DefWindowProc(hwnd, msg, wparam, lparam));
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hInstance;
winclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ID_ICON1));
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = "WINCLASS1";
winclass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(ID_ICON1));
if(!RegisterClassEx(&winclass))
return(0);
if(!(hwnd = CreateWindowEx(NULL,
"WINCLASS1",
"My Awesome Window!",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,0,
400,400,
NULL,
NULL,
hInstance,
NULL)))
return(0);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return(msg.wParam);
}
[\source]
The .h file:
[source]
#define ID_ICON1 100
To use a resource.
Tell me why anything won''t show up!
The main .cpp file:
There''s also a .rc file with the ID_ICON1 in it.
----------------------
Always will be smarter
than you,
--=ME=--
----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
You never called ShowWindow.
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
Never mind. But how do you change the icon on the top left hand corner? And also, how do you make the icons so there''s no background(transparent)?
----------------------
Always will be smarter
than you,
--=ME=--
----------------------
----------------------
Always will be smarter
than you,
--=ME=--
----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
What?
----------------------
Always will be smarter
than you,
--=ME=--
----------------------
----------------------
Always will be smarter
than you,
--=ME=--
----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
Creating a transparent icon has to be done when creating the icon bitmap. Setting the small icon is a question of ensuring there is a 16x16 icon in your .ico and resource file. Also take a look at the LoadImage function (look it up at MSDN).
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
I know about the LoadIcon() function. The question I have is: Where do you put the code of the .rc file like that shown in Lamoth''s book Tricks of the Windows Programming Gurus?
----------------------
Always will be smarter
than you,
--=ME=--
----------------------
----------------------
Always will be smarter
than you,
--=ME=--
----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
Ok, it was out of my ignorance that the LoadIcon() didn''t work. I didn''t know it was for the icon on the bottom(the Start menu) and for the icon used for the shortcut to it. Now, how do you make an icon for the top left hand corner of a window? And how do you make it have a transparent background? Also, when I Load a cursor for a windows class, it doesn''t do anything for the cursor. It just stays the same as a default windows cursor.
----------------------
Always will be smarter
than you,
--=ME=--
----------------------
----------------------
Always will be smarter
than you,
--=ME=--
----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
LoadImage
SetCursor
Look ''em up.
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
SetCursor
Look ''em up.
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
Dont'' you mean LoadIcon??
----------------------
Always will be smarter
than you,
--=ME=--
----------------------
----------------------
Always will be smarter
than you,
--=ME=--
----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
No, LoadImage:
[Edit: unnecessary spacing.]
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
[edited by - Oluseyi on April 16, 2002 7:03:50 PM]
HICON hIconSm = LoadImage( hInstance, MAKEINTRESOURCE( MYICON ), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR );
[Edit: unnecessary spacing.]
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
[edited by - Oluseyi on April 16, 2002 7:03:50 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement