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! :thumbd: :mad:
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? :confused:
Re: Continous sending of WM_PAINT message
One more question: what are "Default painting" and "Modified painting"? how are they implemented?
Re: Continous sending of WM_PAINT message
Quote:
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
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?
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;
}
Re: Continous sending of WM_PAINT message
I have to repeat my quesrtions:
Quote:
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? :confused:
...
One more question: what are "Default painting" and "Modified painting"? how are they implemented?
Re: Continous sending of WM_PAINT message
Quote:
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:
Quote:
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.
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!