Click here to Skip to main content
15,922,166 members
Home / Discussions / C#
   

C#

 
GeneralRe: Icons in a c# gui Pin
mistery226-Oct-03 10:19
mistery226-Oct-03 10:19 
GeneralcomboBox.SelectedIndex in Win2000 vs. XP Pin
misiek6-Oct-03 2:08
misiek6-Oct-03 2:08 
GeneralConfiguration files Pin
Configuration programmer6-Oct-03 1:36
sussConfiguration programmer6-Oct-03 1:36 
GeneralConfiguration files Pin
Config programmer6-Oct-03 1:34
sussConfig programmer6-Oct-03 1:34 
General"CausesValidation" doesn't work Pin
mitdej5-Oct-03 23:59
mitdej5-Oct-03 23:59 
Generalweb service and xml Pin
zecodela5-Oct-03 22:08
zecodela5-Oct-03 22:08 
Generalpopup menu in C# Pin
zecodela5-Oct-03 18:03
zecodela5-Oct-03 18:03 
GeneralRe: popup menu in C# Pin
J. Dunlap5-Oct-03 18:16
J. Dunlap5-Oct-03 18:16 
Start with a form, and set the BorderStyle to None.

Remove the WS_POPUP style bit, and add the WS_EX_PALETTEWINDOW style:
//style
int nStyle = GetWindowLong(this.Handle, GWL_STYLE);  nStyle^=Win.User.WS_POPUP;
nStyle^=Win.User.WS_POPUPWINDOW;
SetWindowLong(Handle,GWL_STYLE,nStyle); 
 
//extended style
int nExStyle = GetWindowLong(this.Handle, GWL_EXSTYLE);
nExStyle|=WS_EX_PALETTEWINDOW;
SetWindowLong(Handle,GWL_EXSTYLE,nExStyle);


This is needed because otherwise the active form loses focus when focus is on your popup, which is not good.

Grab the mouse capture with SetCapture() when the mouse is outside your menu, and release the capture with ReleaseCapture() when the mouse is inside your menu (so that any contained controls can get mouse messages). Close the popup when a MouseUp event is recieved and the mouse coordinates are outside of the form's bounds. You will also want to close the popup when it recieves a WM_APPACTIVATE message where the app being activated is not your own.

HTH! Smile | :)


""It is impossible to rightly govern the world without God and the Bible." -- George Washington

FLUID UI Toolkit | FloodFill in C# & GDI+







GeneralRe: popup menu in C# Pin
zecodela5-Oct-03 18:24
zecodela5-Oct-03 18:24 
GeneralRe: popup menu in C# Pin
J. Dunlap5-Oct-03 18:31
J. Dunlap5-Oct-03 18:31 
GeneralRe: popup menu in C# Pin
J. Dunlap5-Oct-03 18:33
J. Dunlap5-Oct-03 18:33 
GeneralRe: popup menu in C# Pin
Corinna John5-Oct-03 20:31
Corinna John5-Oct-03 20:31 
GeneralRe: popup menu in C# Pin
Blake Coverett5-Oct-03 21:54
Blake Coverett5-Oct-03 21:54 
GeneralSQL/C# Pin
Harry20005-Oct-03 12:18
Harry20005-Oct-03 12:18 
GeneralRe: SQL/C# Pin
mistery225-Oct-03 13:41
mistery225-Oct-03 13:41 
GeneralRe: SQL/C# Pin
Mike Ellison5-Oct-03 14:16
Mike Ellison5-Oct-03 14:16 
GeneralRe: SQL/C# Pin
Harry20005-Oct-03 17:28
Harry20005-Oct-03 17:28 
GeneralRe: SQL/C# Pin
mistery226-Oct-03 0:13
mistery226-Oct-03 0:13 
GeneralDB IV .DBF Databases Pin
gmhanna5-Oct-03 9:33
gmhanna5-Oct-03 9:33 
GeneralRe: DB IV .DBF Databases Pin
Randhir Sinha6-Oct-03 2:05
Randhir Sinha6-Oct-03 2:05 
GeneralRuntime Object state. Pin
Anonymous5-Oct-03 8:39
Anonymous5-Oct-03 8:39 
GeneralRe: Runtime Object state. Pin
Blake Coverett5-Oct-03 10:31
Blake Coverett5-Oct-03 10:31 
Questionprinter minimum margins?? Pin
mistery225-Oct-03 7:59
mistery225-Oct-03 7:59 
AnswerRe: printer minimum margins?? Pin
Nick Parker5-Oct-03 9:29
protectorNick Parker5-Oct-03 9:29 
GeneralRe: printer minimum margins?? Pin
mistery225-Oct-03 12:04
mistery225-Oct-03 12:04 

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.