-
September 30th, 2013, 05:22 AM
#16
Re: Continous sending of WM_PAINT message
1. If you thought that so bad formatted code is easy to read/understand then you was wrong!
2. What is GetDc?
3. What is ReleaseDc?
4. What are you trying to do within the case ID_CIRCLE: of case WM_COMMAND:? Why "draw a circle" NOT in response to WM_PAINT?
Victor Nijegorodov
-
September 30th, 2013, 05:26 AM
#17
Re: Continous sending of WM_PAINT message
One more question: what are "Default painting" and "Modified painting"? how are they implemented?
Victor Nijegorodov
-
September 30th, 2013, 05:40 AM
#18
Re: Continous sending of WM_PAINT message
Originally Posted by VictorN
One more question: what are "Default painting" and "Modified painting"? how are they implemented?
Initialy before selecting any buttons some drawings are there in the screen that are drawing on the screen through default painting,if user selecting some tool bar button(shapes),that shape will be printing on the screen through modified painting.ID_CIRCLE is the identifier for one tool bar button of circle shape.In my development PC no internet connection,So each time i am typing the code for posting ,so only my coding is looking so bad,Sorry for the inconvienance.
Regards,
Manju
-
September 30th, 2013, 05:47 AM
#19
Re: Continous sending of WM_PAINT message
I don't care whether your "development PC" does or does not "internet connection".
It's up to you to post your actual and properly formatted code if you hope to get some help from this Forum!
What prevents you to copy/paste code from one PC to another? Don't you have some USB stick?
Victor Nijegorodov
-
September 30th, 2013, 06:28 AM
#20
Re: Continous sending of WM_PAINT message
Code:
LRESULT CALLBACK LadderWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc,hdc1;
RECT rc;
g_bFirstPass=true;
switch (message)
{
case WM_PAINT:
{
GetClientRect(hWnd, &rc);
hdc = BeginPaint(hWnd, &ps);
if(hdc==NULL)
{
DWORD dw=GetLastError();
break;
}
else
{
HPEN hOldPen=SelectObject( hdc,hpen2);
if(g_bFirstPass)
{
pLadder->SelectElement(hWnd,hdc,0); //Default painting
}
else if((!g_bEdting))
{
pLadder->SelectElement(hWnd,hdc,pLadder->m_iLastSelectedIndex)//Modified painting
}
SelectObject( hdc,hOldPen);
}
EndPaint(hWnd, &ps);
}
break;
case WM_COMMAND:
{
g_bFirstPass=false;
switch(LOWORD(wParam))
{
// idea got from msdn.microsoft.com/en-us/library/windows/desktop/dd162493
case ID_CIRCLE:
{
hdc1=GetDc(hWnd);//Retrieve a handle to a DC
DrawCircle( hdc1);//calling a function to drawing without WM_PAINT message
ReleaseDc(hWnd,hdc1);//Release Dc
}
break;
}
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
break;
}
return 0;
}
Last edited by manjut19; September 30th, 2013 at 06:30 AM.
-
September 30th, 2013, 07:07 AM
#21
Re: Continous sending of WM_PAINT message
I have to repeat my quesrtions:
Originally Posted by VictorN
2. What is GetDc?
3. What is ReleaseDc?
4. What are you trying to do within the case ID_CIRCLE: of case WM_COMMAND:? Why "draw a circle" NOT in response to WM_PAINT?
...
One more question: what are " Default painting" and " Modified painting"? how are they implemented?
Victor Nijegorodov
-
September 30th, 2013, 07:33 AM
#22
Re: Continous sending of WM_PAINT message
Originally Posted by manjut19
Code:
...
case WM_COMMAND:
{
g_bFirstPass=false;
switch(LOWORD(wParam))
{
// idea got from msdn.microsoft.com/en-us/library/windows/desktop/dd162493
case ID_CIRCLE:
{
hdc1=GetDc(hWnd);//Retrieve a handle to a DC
DrawCircle( hdc1);//calling a function to drawing without WM_PAINT message
ReleaseDc(hWnd,hdc1);//Release Dc
}
break;
...
The link you posted contains this:
An application that enables drawing, as in this example, typically records either the points or lines so that the lines can be redrawn whenever the window is updated.
In other words, you need to do all your drawing in the WM_PAINT handler (or functions that are only called from there). If you draw in the WM_COMMAND handler, whatever you draw will be gone when the window gets repainted.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
-
September 30th, 2013, 07:35 AM
#23
Re: Continous sending of WM_PAINT message
You use GetDC and ReleaseDC to obtain and release a handle to a device context.
Note also that in your WM_PAINT message, g_bFirstPass will always be true as it is always set to true before the switch statement!
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
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
|