WM_SHOWWINDOW problem

I want my window to handle the case
in which is state is changed from shown
to hidden ( and vice versa), but I want
to do it only after the window show status was changed.
The WM_SHOWWINDOW message is sent before the actual visibilty state of the window was changed.
zonaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nils pipenbrinckCommented:
try wm_activate...

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nietodCommented:
This doesn't seem to have anything to do with WM_ACTIVATE or its associated messages or anything to do with activation.

zona, I'm having trouble understanding the question.  But it sounds like you want to do something AFTER the window has been hidden/shown.  Is that right?   If so, just handle the WM_SHOWWINDOW message by calling the default window procedure and then when that procedure returns, perform your processing.
0
NickRepinCommented:
You have to post user-defined message from the WM_SHOWWINDOW message:

#define WMU_WINDOW_IS_SHOWN   WM_USER+1

case WM_SHOWWINDOW:
   // Post, but not send
   PostMessage(hWnd,WMU_WINDOW_IS_SHOWN,0,0);
   break;

case WMU_WINDOW_IS_SHOWN:
   if(IsWindowVisible(hWnd) {
      // Window just have been shown
   }
   else {
      // Window just have been hidden
   }
   break;
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

nietodCommented:
Why?  If would be sufficient to handle the WM_SHOWWINDOW After the default window procedure has hidden/shown the window.
0
NickRepinCommented:
Here is the test program.

OptionA: we call DefWindowProc and stops to see what's happened. Nothing.
Window is hidden.

OptionB: window is visible.


WM_SHOWWINDOW doesn't show window itself. I mean, you can skip DefWindowProc(WM_SHOWWINDOW) and return 0, but window will be shown anyway.


#include <windows.h>
#include <iostream.h>
#include <conio.h>

#define WMU_SHOWN WM_USER+1

LRESULT CALLBACK wndProc(HWND w,UINT msg,WPARAM wp,LPARAM lp)
{
   switch(msg) {
   case WM_CLOSE:
      PostQuitMessage(0);
      break;
   case WM_SHOWWINDOW:
     cout<<"Show"<<endl;
//***********
// Option A
//***********
     LRESULT r=DefWindowProc(w,msg,wp,lp);
     getch();
     cout<<"After getch"<<endl;
     return r;
//************

//***********
// Option B
//***********
     PostMessage(w,WMU_SHOWN,0,0);
     return 0;
   case WMU_SHOWN:
     cout<<"WNU_SHOWN"<<endl;
     getch();
     cout<<"After getch"<<endl;
     return 0;
//**********
   }
   return DefWindowProc(w,msg,wp,lp);
}

void main(void)
{
   WNDCLASS cls;
   memset(&cls,0,sizeof(cls));
   cls.lpfnWndProc=wndProc;
   cls.hInstance=GetModuleHandle(0);
   cls.lpszClassName="AZA";
   cls.hbrBackground=HBRUSH(COLOR_WINDOW+1);
   RegisterClass(&cls);
   MSG msg;
   PeekMessage(&msg,0,WM_USER,WM_USER,PM_NOREMOVE);
   HWND w=CreateWindowEx(0,"AZA","test",WS_POPUP|WS_CAPTION|WS_SYSMENU|
      WS_VISIBLE,
      5,5,200,200,0,0,cls.hInstance,0);
   while(GetMessage(&msg,0,0,0)) {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }
}
0
NickRepinCommented:
By the way, zona has 8/19 grading record. So I think our dispute is useless.
0
chensuCommented:
NickRepin is on the right track. I often use PostMessage with a user-defined message in this case. Many Windows messages have not completely finished their jobs when the messages are received. Therefore, you have to wait.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.