|
-
June 11th, 2011, 07:36 PM
#1
Drawing an icon
Hi, I know that:
//here im creating a handle to an icon...
HICON hIcon;
//here im loading the icon into to the icon variable...
hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
//here im creating a handle to a device context..
HDC handleDeviceContext;
From this point onwards could you explain to me what exactly is going on I know how to use these, and have a fair idea of whats happening, but i want to hear it from you people 
PAINTSTRUCT PaintSt;
handleDeviceContext = BeginPaint(hWnd, &PaintSt);
DrawIcon(handleDeviceContext, X, Y, hIcon);
EndPaint(hWnd, &PaintSt);
-
June 12th, 2011, 01:00 AM
#2
Re: Drawing an icon
PAINTSTRUCT PaintSt;
handleDeviceContext = BeginPaint(hWnd, &PaintSt);
DrawIcon(handleDeviceContext, X, Y, hIcon);
EndPaint(hWnd, &PaintSt);
// Is something unclear in the above links?
-
June 12th, 2011, 04:50 PM
#3
Re: Drawing an icon
Ok, so...
//here we're making a structure which holds information about how we are gonna paint in the client area...
PAINTSTRUCT PaintSt;
//here we are calling the beginpaint function and passing its return value to the HDC variable. By calling this function im not too sure of what we're doing and why we pass its return value.
handleDeviceContext = BeginPaint(hWnd, &PaintSt);
//here we are drawing the icon on scren...
DrawIcon(handleDeviceContext, X, Y, hIcon);
//This function is called at the end of painting (not exactly sure why we have to tho)
EndPaint(hWnd, &PaintSt);
-
June 13th, 2011, 06:00 PM
#4
Re: Drawing an icon
?
-
June 14th, 2011, 02:19 AM
#5
Re: Drawing an icon
BeginPaint returns a...
[MSDN Library]
...handle to a display device context for the specified window...
... which is necessary for GDI functions that perform painting or drawing.
What other stuff does BeginPaint, as well as any other WinAPI function?
You can find out by paying attention to its whole documentation including parameters, return value, remarks, examples, and see also sections.
DrawIcon is a GDI function which requires a handle to a device context. In our case, this handle has been returned by BeginPaint.
EndPaint is called because...
[MSDN Library]
...this function is required for each call to the BeginPaint function after the painting is complete.
What is a device context? Which are painting and drawing functions? How to draw in the client area?...
See MDSN Library, MSDN Library, MSDN Library,...
// Please document yourself, as much as possible, before posting quiz-like questions in discussion forums!
// Windows programming is quite difficult to learn if you don't know its basics.
// Beside MSDN Library, I would like to recommend books like:
[ Moved thread ]
Last edited by ovidiucucu; June 14th, 2011 at 02:25 AM.
Reason: typos
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|