Click here to Skip to main content
15,890,845 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Best way to reduce a 128-bit MD5 to 64-bit Pin
Joe Woodbury5-Mar-11 6:04
professionalJoe Woodbury5-Mar-11 6:04 
QuestionCCriticalSection seems to cause some weirdness in dll Pin
Albert Holguin4-Mar-11 10:49
professionalAlbert Holguin4-Mar-11 10:49 
AnswerRe: CCriticalSection seems to cause some weirdness in dll Pin
Ozer Karaagac4-Mar-11 13:31
professionalOzer Karaagac4-Mar-11 13:31 
GeneralRe: CCriticalSection seems to cause some weirdness in dll Pin
Albert Holguin4-Mar-11 13:40
professionalAlbert Holguin4-Mar-11 13:40 
QuestionHow can I send LVN_COLUMNCLICK to the parent ? Pin
_Flaviu4-Mar-11 8:59
_Flaviu4-Mar-11 8:59 
AnswerRe: How can I send LVN_COLUMNCLICK to the parent ? Pin
Hans Dietrich4-Mar-11 18:46
mentorHans Dietrich4-Mar-11 18:46 
GeneralRe: How can I send LVN_COLUMNCLICK to the parent ? [modified] Pin
_Flaviu4-Mar-11 20:57
_Flaviu4-Mar-11 20:57 
Questionproblem with device context (and some other bad things) Pin
csrss4-Mar-11 8:38
csrss4-Mar-11 8:38 
Here is my drama. I have created a class, which is responsible for creating main application window, applying vista glass effect to it and setting background image - all in one. So now i have, kind of, 2 window procedures - one is inside a class, which is responsible for painting candy look vista transparency and bkg pic, and one is outside the class, which is responsible for command events and such, but also for painting some additional controls. So currently i have 2 different WM_PAINT's. The problem is - i cannot paint anything in 2'nd WM_PAINT (which is outside the class) while i can paint everything inside a class. And there is no difference if i export a handle to device context from class to 2'nd wndproc - i just cannot paint anything outside class. Here are steps (in code):

// this is passed to RegisterClassExW
static LRESULT CALLBACK mWindow::WndProc(IN HWND hwnd, 
					 IN UINT uMsg, 
					 IN WPARAM wParam, 
					 IN LPARAM lParam)
{
	mWindow *self;
	if (uMsg == WM_NCCREATE) {
		LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
		self = (mWindow *)lpcs->lpCreateParams;
		SetWindowLongPtr(hwnd, GWLP_USERDATA, (LPARAM)self);
	} 
	else 
	{
		self = (mWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
	}
	if (self) 
	{
		return self->InternalWndProc(hwnd, uMsg, wParam, lParam); // this is my first wndproc
	} 
	else 
	{
		return DefWindowProc(hwnd, uMsg, wParam, lParam);
	}
}

__w64 long __stdcall InternalWndProc(IN HWND hWnd, 
				IN unsigned int msg, 
				 IN __w64 unsigned int wParam, 
				 IN __w64 long lParam)
{
    switch(msg)
    {
         // here i am doing some pre painting, glass, background image, window moving handler, etc
          case wm_paint: 
              OnPaint(); // inside OnPaint (among other things) i am saving current HDC, which then can be exported from class
                         // like this: myWindow->operator HDC();
          break;
          default:
	         return _outer_procedure(hWnd, msg, wParam, lParam);
	}
return _outer_procedure(hWnd, msg, wParam, lParam); // this is my second wndproc, which outside a class
}

// so when "msg" is processed, this wndproc "jumps" to wndproc outside a class ->

__w64 long __stdcall WndProc(IN HWND hWnd,  // this is my "_outer_procedure"
				IN unsigned int msg, 
				IN __w64 unsigned int wParam, 
				IN __w64 long lParam)
{
    switch(msg)
    {
         case WM_PAINT: // and now i am simply trying to draw a single black line
		{
			Gdiplus::Graphics graphics((HDC)AppWindow->operator HDC());
			Gdiplus::Pen      pen(Gdiplus::Color::Black);
			graphics.DrawLine(&pen, 100, 100, 200, 100);
		}
		break; // which fails badly, and there is no difference, if i do BeginPaint / EndPaint or simply 
//import hdc from a class. while inporting HDC - it has same address in memory like in class
    }
}


So, what is going on here? Maybe after 1'st WM_PAINT handle to device context becomes invalid and not reusable? I just dont know. Thanks for any help.
011011010110000101100011011010000110100101101110
0110010101110011

QuestionRe: problem with device context (and some other bad things) Pin
CPallini4-Mar-11 9:50
mveCPallini4-Mar-11 9:50 
AnswerRe: problem with device context (and some other bad things) Pin
csrss4-Mar-11 9:56
csrss4-Mar-11 9:56 
AnswerRe: problem with device context (and some other bad things) Pin
Ozer Karaagac4-Mar-11 14:17
professionalOzer Karaagac4-Mar-11 14:17 
GeneralRe: problem with device context (and some other bad things) Pin
csrss4-Mar-11 15:40
csrss4-Mar-11 15:40 
AnswerRe: problem with device context (and some other bad things) Pin
Richard MacCutchan4-Mar-11 22:17
mveRichard MacCutchan4-Mar-11 22:17 
GeneralRe: problem with device context (and some other bad things) Pin
csrss5-Mar-11 0:53
csrss5-Mar-11 0:53 
QuestionSending windows message from worker thread Pin
GC1044-Mar-11 0:41
GC1044-Mar-11 0:41 
AnswerRe: Sending windows message from worker thread Pin
CPallini4-Mar-11 1:47
mveCPallini4-Mar-11 1:47 
GeneralRe: Sending windows message from worker thread Pin
GC1044-Mar-11 2:29
GC1044-Mar-11 2:29 
GeneralRe: Sending windows message from worker thread Pin
prasad_som4-Mar-11 2:33
prasad_som4-Mar-11 2:33 
GeneralRe: Sending windows message from worker thread Pin
CPallini4-Mar-11 3:05
mveCPallini4-Mar-11 3:05 
GeneralRe: Sending windows message from worker thread Pin
CPallini4-Mar-11 2:36
mveCPallini4-Mar-11 2:36 
AnswerRe: Sending windows message from worker thread Pin
prasad_som4-Mar-11 2:30
prasad_som4-Mar-11 2:30 
QuestionGetting Time Difference [modified] Pin
AmbiguousName3-Mar-11 22:29
AmbiguousName3-Mar-11 22:29 
AnswerRe: Getting Time Difference Pin
CPallini3-Mar-11 22:46
mveCPallini3-Mar-11 22:46 
AnswerRe: Getting Time Difference Pin
Cool_Dev3-Mar-11 23:40
Cool_Dev3-Mar-11 23:40 
AnswerRe: Getting Time Difference Pin
David Crow4-Mar-11 2:07
David Crow4-Mar-11 2:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.