I have a problem with this Window Procedure. in new versions of Windows OS, when I run the program, at first everything is painted & then paintings disappear (until the window receives the next paint message)

long _stdcall WndProc
	(
	HWND hwnd,
	unsigned msg,
	unsigned wParam,
	long lParam
	)
{
	if(!peb1)
		return DefWindowProc(hwnd,msg,wParam,lParam);

	switch(msg)
	{
		case WM_CREATE:
		{
			return 0;
		}

		case WM_ACTIVATE:
		case WM_SIZING:
		{
			DefWindowProc(hwnd,msg,wParam,lParam);
		   //	Paint();
			return 0;
		}

		case WM_ERASEBKGND:
		{
			DefWindowProc(hwnd,msg,(unsigned)v_hdc,lParam);
			//return 0;
		}

		case WM_PAINT:
		{
			peb1 -> V_Paint();
			peb2 -> V_Paint();
			peb3 -> V_Paint();
			pbtn1 -> V_Paint();
			pbtn2 -> V_Paint();
			pbtn3 -> Paint();

			return DefWindowProc(hwnd,msg,wParam,lParam);
		}

		case WM_SYSCOMMAND:
		{
			DefWindowProc(hwnd,msg,wParam,lParam);
			switch(wParam)
			{
				/*case SC_MAXIMIZE:
				case SC_RESTORE:
					Paint();  */
			}
			return 0;
		}

		case WM_MOUSEWHEEL:
		{
			peb1 -> wmMousewheel(wParam,lParam);
			peb2 -> wmMousewheel(wParam,lParam);
			return 0;
		}

		case WM_MOUSEMOVE:
		{
			TrackLeave(hwnd);

			peb1 -> wmMousemove(lParam);
			peb2 -> wmMousemove(lParam);

			return 0;
		}

		case WM_MOUSELEAVE:
		{
			//MessageBeep(-1);
			return 0;
		}

		case WM_MOUSEHOVER:
		{

			return 0;
		}

		case WM_LBUTTONDOWN:
		{
			peb1 -> wmLbuttondown(lParam);
			peb2 -> wmLbuttondown(lParam);
			pbtn1 -> wmLbuttondown(lParam);
			pbtn2 -> wmLbuttondown(lParam);
			pbtn3 -> wmLbuttondown(lParam);
			return 0;
		}

		case WM_LBUTTONUP:
		{
			peb1 -> wmLbuttonup(lParam);
			peb2 -> wmLbuttonup(lParam);
			pbtn1 -> wmLbuttonup(lParam);
			pbtn2 -> wmLbuttonup(lParam);
			pbtn3 -> wmLbuttonup(lParam);
			return 0;
		}

		case WM_RBUTTONDOWN:
		{

			return 0;
		}

		case WM_CLOSE:
		{
			DestroyWindow(hwnd);
			return 0;
		}

		case WM_DESTROY:
		{
			delete peb1;
			delete peb2;
			PostQuitMessage(0);
			return 0;
		}

		case WM_CHAR:
		{
			peb1 -> wmChar(wParam);
			peb2 -> wmChar(wParam);
			return 0;
		}

		case WM_TIMER:
		{

			return 0;
		}

		case WM_KEYDOWN:
		{
			peb1 -> wmKeydown(wParam);
			peb2 -> wmKeydown(wParam);
			return 0;
		}

		case WM_SYSKEYDOWN:
		{
			peb1 -> wmSyskeydown(wParam);
			peb2 -> wmSyskeydown(wParam);
			return 0;
		}

		default:
			return DefWindowProc(hwnd,msg,wParam,lParam);
	}
}

there's also a problem with mouse click messages. I think they are not caught properly by window procedure.
there's no problem in Windows XP. These problems are in Vista & Seven.
I can attach all the project if necessary!

Edited 6 Years Ago by CppBuilder2006: n/a

I'm not sure what the problem is going to be explicitly, but you might want to try adding paint() on activate aswell as on paint itself.

I remember having an issue with when the window was drawing with VIsta but went away when I used a different approach. You could place paint calls explicitly in your frame handler rather than just to listen for WMPAINT

I have a problem with this Window Procedure. in new versions of Windows OS, when I run the program, at first everything is painted & then paintings disappear
there's also a problem with mouse click messages. I think they are not caught properly by window procedure.
there's no problem in Windows XP. These problems are in Vista & Seven.
I can attach all the project if necessary!

Edited 3 Years Ago by mike_2000_17: Fixed formatting

You could place paint calls explicitly in your frame handler rather than just to listen for WMPAINT

do you mean WM_NCPAINT!?

I'm not sure what the problem is going to be explicitly

this is link to download all project!

MRKtack.exe!VisualEditBox::LineMinMax+0x6a
MRKtack.exe!VisualEditBox::Refresh+0x7e
MRKtack.exe!VisualEditBox::InternalPaint+0x3b
MRKtack.exe!SelectEditBox::MouseSetCaret+0x242
MRKtack.exe!UndoEditBox::MouseSetCaret+0x14a
MRKtack.exe!SelectEditBox::StartSelection+0x40
MRKtack.exe!EditBox::wmLbuttondown+0x130
MRKtack.exe!WndProc+0x2bd
USER32.dll!UserCallWinProc+0x18
USER32.dll!DispatchMessageWorker+0x2e4
USER32.dll!DispatchMessageW+0xb
MRKtack.exe!Window::MessageLoop+0x5f
MRKtack.exe!Window::Run+0x2b
MRKtack.exe!WinMain+0x82d
MRKtack.exe!__tmainCRTStartup+0x286
MRKtack.exe!WinMainCRTStartup+0xd
KERNEL32.dll!BaseProcessStart+0x3d

To point out at least one immediate problem, it gets 'stuck' in the LineMinMax() doing some lengthy calculations there. When it stops responding, break it into the debugger and watch the values being used inside the loops.

There were a rather large number of warnings of many kinds, maybe you should be paying some attention to them.

thanks for downloading! but there's no problem in Windows XP!

so the problem is with Windows messages! which I think there are differences in newer versions of Windows!

about LineMinMax, yes there were some marginal problems which were fixed!

but my main problem is in newer versions of Windows. Paintings are disppeared unexpectedly in Vista/Seven!

large number of warnings

yes in Visual C++! but in C++Builder there's no warnings! ;)

This article has been dead for over six months. Start a new discussion instead.