Difference between revisions of "Forms & Dialogs"

From Team Developer SqlWindows Wiki
Jump to: navigation, search
m (Deleted enter new tip title section)
(Added sample "ShowWindowOnTaskbar" for windows having accessories enabled.)
Line 17: Line 17:
 
On creation of the window, set the GWL_EXSTYLE to WS_EX_APPWINDOW.<br>
 
On creation of the window, set the GWL_EXSTYLE to WS_EX_APPWINDOW.<br>
 
<br>
 
<br>
First declare these external functions and system constants:<br>
+
Beware, a top level window with accessories enabled has a different internal window hierarchy compared to<br>
 +
a window without accessories.<br>
 +
For top level windows having accessories, hWndForm should be changed to the parent of hWndForm.<br>
 +
You can not use SalParentWindow, that function will return the owner of the window.<br>
 +
You need to call GetParent from WinApi as declared above.<br>
 +
<br>
 +
So, declare these external functions and system constants:<br>
 
<pre>
 
<pre>
 
Library name: USER32.DLL
 
Library name: USER32.DLL
Line 36: Line 42:
 
         Number: INT
 
         Number: INT
 
         Number: LONG
 
         Number: LONG
 +
 +
  Function: GetParent
 +
      Export Ordinal: 0
 +
      Returns
 +
        Window Handle: HWND
 +
      Parameters
 +
        Window Handle: HWND
  
  
Line 44: Line 57:
 
</pre>
 
</pre>
  
Now, set the WS_EX_APPWINDOW style to the window at creation:<br>
+
For top level windows without accessories enabled, do this:<br>
 +
set the WS_EX_APPWINDOW style to the window (hWndForm) at creation:<br>
  
 
<pre>
 
<pre>
Line 51: Line 65:
 
</pre>
 
</pre>
  
The window will be shown on the taskbar.<br>
+
For top level windows WITH accessories enabled, do this:<br>
 +
set the WS_EX_APPWINDOW style to the parent window of hWndForm at creation:<br>
 +
 
 +
<pre>
 +
On SAM_Create
 +
  Call SetWindowLongA( GetParent( hWndForm ), GWL_EXSTYLE, GetWindowLongA( GetParent( hWndForm ), GWL_EXSTYLE ) | WS_EX_APPWINDOW )
 +
</pre>
 +
 
 +
The window will then be shown on the taskbar.<br>
 
<br>
 
<br>
  
 
Here you can download a sample:
 
Here you can download a sample:
*[http://samples.tdcommunity.net/index.php?dir=&file=WIKI_ShowWindowOnTaskbar.zip WIKI_ShowWindowOnTaskbar.zip]<br>
+
*[http://samples.tdcommunity.net/index.php?dir=&file=WIKI_ShowWindowOnTaskbarWithAccessories.zip WIKI_ShowWindowOnTaskbarWithAccessories.zip]<br>
 
<br>
 
<br>

Revision as of 08:40, 9 September 2011

This page covers Form Window and DialogBox tips & tricks.

Contents


Pointer2.png How to drag a window without a caption Pointer.png

See Windows messages : How to drag a window without a caption


Pointer2.png How to force a window on the taskbar Pointer.png

When a top-level window is created without a specific parent (hWndNULL) the window will be visible on the Windows taskbar.
Windows created using a parent, will not be shown.

To be able to use a parent while creating a window AND having it placed on the taskbar, use the following:
On creation of the window, set the GWL_EXSTYLE to WS_EX_APPWINDOW.

Beware, a top level window with accessories enabled has a different internal window hierarchy compared to
a window without accessories.
For top level windows having accessories, hWndForm should be changed to the parent of hWndForm.
You can not use SalParentWindow, that function will return the owner of the window.
You need to call GetParent from WinApi as declared above.

So, declare these external functions and system constants:

Library name: USER32.DLL
   Function: GetWindowLongA
      Export Ordinal: 0
      Returns
         Number: LONG
      Parameters
         Window Handle: HWND
         Number: INT

   Function: SetWindowLongA
      Export Ordinal: 0
      Returns
         Number: LONG
      Parameters
         Window Handle: HWND
         Number: INT
         Number: LONG

   Function: GetParent
      Export Ordinal: 0
      Returns
         Window Handle: HWND
      Parameters
         Window Handle: HWND


Constants
   System
      Number: GWL_EXSTYLE	= -20
      Number: WS_EX_APPWINDOW	= 0x00040000

For top level windows without accessories enabled, do this:
set the WS_EX_APPWINDOW style to the window (hWndForm) at creation:

On SAM_Create
   Call SetWindowLongA( hWndForm, GWL_EXSTYLE, GetWindowLongA( hWndForm, GWL_EXSTYLE ) | WS_EX_APPWINDOW )

For top level windows WITH accessories enabled, do this:
set the WS_EX_APPWINDOW style to the parent window of hWndForm at creation:

On SAM_Create
   Call SetWindowLongA( GetParent( hWndForm ), GWL_EXSTYLE, GetWindowLongA( GetParent( hWndForm ), GWL_EXSTYLE ) | WS_EX_APPWINDOW )

The window will then be shown on the taskbar.

Here you can download a sample: