[C++] Message envoyé à une fenêtre lors de sa minimisation ?

Message envoyé à une fenêtre lors de sa minimisation ? [C++] - C++ - Programmation

Marsh Posté le 11-04-2002 à 17:21:05    

J'ai regardé tous les messages WM_ mais j'ai rien trouvé correspondant à ce que je cherches  :heink:  
 
Si qq'un pourrait me dire quel message je dois utiliser, ce serait cool ;)

Reply

Marsh Posté le 11-04-2002 à 17:21:05   

Reply

Marsh Posté le 11-04-2002 à 17:25:26    

C'est le message WM_SIZE avec SIZE_MINIMIZED en wParam


---------------
"Dieu a exploité tous nos complexes d'infériorité, en commençant par notre incapacité de croire à notre propre divinité." - Emil Michel Cioran
Reply

Marsh Posté le 11-04-2002 à 17:26:01    

Ok, j'vais voir ça de plus près, merci bcp ;)
 
 :hello:

Reply

Marsh Posté le 11-04-2002 à 17:41:24    

J'aurais plutot penché pour un WM_SYSCOMMAND avec un SC_MINIMIZE


---------------
Vendredi c'est Buitoni
Reply

Marsh Posté le 11-04-2002 à 17:41:39    

A window receives this message when the user chooses a command from the window menu (also known as the System menu or Control menu) or when the user chooses the Maximize button or Minimize button.
 
WM_SYSCOMMAND  
uCmdType = wParam;        // type of system command requested  
xPos = LOWORD(lParam);    // horizontal postion, in screen coordinates  
yPos = HIWORD(lParam);    // vertical postion, in screen coordinates  
 
 
Parameters
 
uCmdType
 
Specifies the type of system command requested. This can be one of these values:
 
Value Meaning
SC_CLOSE Closes the window.
SC_CONTEXTHELP Changes the cursor to a question mark with a pointer. If the user then clicks a control in the dialog box, the control receives a WM_HELP message.
SC_DEFAULT Selects the default item; the user double-clicked the window menu.
SC_HOTKEY Activates the window associated with the application-specified hot key. The low-order word of lParam identifies the window to activate.
SC_HSCROLL Scrolls horizontally.
SC_KEYMENU Retrieves the window menu as a result of a keystroke.
SC_MAXIMIZE (or SC_ZOOM) Maximizes the window.
SC_MINIMIZE (or SC_ICON) Minimizes the window.
SC_MONITORPOWER Windows 95 only: Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer.
SC_MOUSEMENU Retrieves the window menu as a result of a mouse click.
SC_MOVE Moves the window.
SC_NEXTWINDOW Moves to the next window.
SC_PREVWINDOW Moves to the previous window.
SC_RESTORE Restores the window to its normal position and size.
SC_SCREENSAVE Executes the screen saver application specified in the [boot] section of the SYSTEM.INI file.
SC_SIZE Sizes the window.
SC_TASKLIST Executes or activates Windows Task Manager.
SC_VSCROLL Scrolls vertically.
 
 
xPos
 
Specifies the horizontal position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. Otherwise, the xPos parameter is not used.
 
yPos
 
Specifies the vertical position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. This parameter is -1 if the command is chosen using a system accelerator, or zero if using a mnenomic.
 
 
 
Return Values
 
An application should return zero if it processes this message.
 
Remarks
 
The DefWindowProc function carries out the window menu request for the predefined actions specified in the previous table.  
In WM_SYSCOMMAND messages, the four low-order bits of the uCmdType parameter are used internally by Windows. To obtain the correct result when testing the value of uCmdType, an application must combine the value 0xFFF0 with the uCmdType value by using the bitwise AND operator.  
The menu items in a window menu can be modified by using the GetSystemMenu, AppendMenu, InsertMenu, ModifyMenu, InsertMenuItem, and SetMenuItem functions. Applications that modify the window menu must process WM_SYSCOMMAND messages.
 
An application can carry out any system command at any time by passing a WM_SYSCOMMAND message to DefWindowProc. Any WM_SYSCOMMAND messages not handled by the application must be passed to DefWindowProc. Any command values added by an application must be processed by the application and cannot be passed to DefWindowProc.  
Accelerator keys that are defined to choose items from the window menu are translated into WM_SYSCOMMAND messages; all other accelerator keystrokes are translated into WM_COMMAND messages.  
 
See Also
 
AppendMenu, DefWindowProc, GetSystemMenu, InsertMenu, ModifyMenu, WM_COMMAND


---------------
Vendredi c'est Buitoni
Reply

Marsh Posté le 11-04-2002 à 17:42:41    

Je suis pas totalement gateux :
 
WM_SIZE
The WM_SIZE message is sent to a window after its size has changed.  
 
A window receives this message through its WindowProc function.  
 
LRESULT CALLBACK WindowProc(
  HWND hwnd,       // handle to window
  UINT uMsg,       // WM_SIZE
  WPARAM wParam,   // resizing flag
  LPARAM lParam    // client area
);
Parameters
wParam  
Specifies the type of resizing requested. This parameter can be one of the following values. Value Meaning  
SIZE_MAXHIDE Message is sent to all pop-up windows when some other window is maximized.  
SIZE_MAXIMIZED The window has been maximized.  
SIZE_MAXSHOW Message is sent to all pop-up windows when some other window has been restored to its former size.  
SIZE_MINIMIZED The window has been minimized.  
SIZE_RESTORED The window has been resized, but neither the SIZE_MINIMIZED nor SIZE_MAXIMIZED value applies.  
 
 
lParam  
The low-order word of lParam specifies the new width of the client area.  
The high-order word of lParam specifies the new height of the client area.

 

[jfdsdjhfuetppo]--Message édité par Tetragrammaton IHVH--[/jfdsdjhfuetppo]


---------------
"Dieu a exploité tous nos complexes d'infériorité, en commençant par notre incapacité de croire à notre propre divinité." - Emil Michel Cioran
Reply

Marsh Posté le 11-04-2002 à 19:34:05    

Yep ! En fait c'était WM_SYSCOMMAND !
 
Merci Buitoni ;)
 
J'ai une autre question, je chope ce message donc je peux faire mon traitement qd WParam = SC_MINIMIZE mais tous les autres params sont bien évidemment capturés et j'ai pas envie de m'amuser à redéfinir le comportement de l'appli pour chaque param..j'suis pas fou :pt1cable:  
J'pensais faire un TranslateMessage() un truc comme ça mais ça sert à rien, j'entrerais dans une boucle infinie .. :non:  
 
Comment on fait dans ce cas là ??
 
NB : j'utilise BCB3

 

[jfdsdjhfuetppo]--Message édité par *Syl*--[/jfdsdjhfuetppo]

Reply

Marsh Posté le 11-04-2002 à 19:47:35    

procedure TfoMain.WMSysCommand(var Message: TWMSysCommand);
begin
  if (Message.CmdType and $FFF0 = SC_CLOSE) then
    Application.Minimize
  else
    inherited;
end;
 
Traduis ca en C++ ;)

 

[jfdsdjhfuetppo]--Message édité par Buitoni--[/jfdsdjhfuetppo]


---------------
Vendredi c'est Buitoni
Reply

Marsh Posté le 11-04-2002 à 19:54:51    

Buitoni a écrit a écrit :

procedure TfoMain.WMSysCommand(var Message: TWMSysCommand);
begin
  if (Message.CmdType and $FFF0 = SC_CLOSE) then
    Application.Minimize
  else
    inherited;
end;
 
Traduis ca en C++ ;)  
 
 




Héhé, avant de poster, j'avais étais faire un tour sur inherited vu que j'connais un peu Delphi :)
En fait faut que j'appelle la méthode qui traite les messages habituellement donc j'avais fait ça :
 
if(prmMes.WParam == SC_MINIMIZE) ShowMessage("Min" ) ;
WndProc(prmMes);
 
Mais comme prévu j'ai l'droit à ma boucle infinie..
Bon je continue de chercher..J'trouverais bien :)
 
'Rci ;)

 

[jfdsdjhfuetppo]--Message édité par *Syl*--[/jfdsdjhfuetppo]

Reply

Marsh Posté le 11-04-2002 à 20:02:31    

C'est bon j'viens d'avoir une idée : je vire le message SC_MINIMIZE de prmMes.WParam avant de le renvoyer à WndProc, ça devrait marcher  :sol:  
 
Bon..j'testerais ça après avoir bouffer parce que là j'ai la dale :D
 
 :hello:

Reply

Marsh Posté le 11-04-2002 à 20:02:31   

Reply

Marsh Posté le 11-04-2002 à 20:21:29    

P'tain ! Ça marche pas et c'est normal puisque le boucle est tjrs là à cause de l'appel à WndProc !
 
Arf, j'suis con, c'était logique en + que ça allait pas marcher.. :crazy:

 

[jfdsdjhfuetppo]--Message édité par *Syl*--[/jfdsdjhfuetppo]

Reply

Marsh Posté le 11-04-2002 à 21:44:13    

YEEEEESSSSSSS ! I've got the solution ! :sol:  
 
J'étais parti pour créer une nvelle boucle de messages, le truc bien lourd quoi lorsque je suis tombé sur Dispatch() qui était la solution à tous mes pb :)
 
En fait, dans la méthode traitant SC_MINIMIZE, il suffit de rajouter TForm::Dispatch(&prmMes) ; pour que le process des messages s'effectue normalement  :pt1cable:  
 
Wouuuahhhhhooouuuuuu ! :pt1cable:

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed