Shoutbox

[VB6] vbModeless? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: [VB6] vbModeless? (/showthread.php?tid=51622)

[VB6] vbModeless? by eSouL on 10-10-2005 at 05:02 PM

Hi, another one from me, sorry for the never-ending questions.. :$

When i do this:
form1.show vbmodeless

Nothing happens. the form will show up only when I use vbModal for it. Why is it so?


RE: [VB6] vbModeless? by Mike on 10-10-2005 at 05:08 PM

The variable "vbModeless" is actually unknown in VB, and I guess you get a compile error saying "Variable Not Defined" when trying to compile your plugin.
If you don't get an error, that means that you haven't put "Option Explicit" in the top of your code.
That forces every variable to be declared.

Anyway, if you want to show a "modeless" form, you don't have to put "vbModel".
However, you can't use this on a Messenger Plus! VB plugin.
But I think that Matty has made a post on how to make a "modeless" form in a plugin...


RE: [VB6] vbModeless? by matty on 10-10-2005 at 06:51 PM

The .Show function on a form accepts 2 values for the type of Display. Those values are 0 and 1. 0 would, in essence vbModaless which doesn't technically exist as a Visual Basic Constant. And 1 is vbModal (showing ontop of all other windows.

Now when showing a window from a plugin you have to use vbModal if you choose to show a window using Formname.show. On the other hand if you use the Windows API as shown in the post i made awhile ago you can do it differently.

Matty's reply to Showing Form without vbModal in VB? For the programmers out there... :D


RE: [VB6] vbModeless? by CookieRevised on 10-10-2005 at 11:21 PM

quote:
Originally posted by Mike
The variable "vbModeless" is actually unknown in VB, and I guess you get a compile error saying "Variable Not Defined" when trying to compile your plugin.
No, vbModeless _does_ exist and is a perfect valid constant...

Show parameters:
Constant      Value       Description
vbModal            1        Modal form
vbModeless        0        Modeless form

See VB help files, or MSDN Library: Form constants

quote:
Originally posted by Mike
Anyway, if you want to show a "modeless" form, you don't have to put "vbModel".
Indeed you don't, as "Modeless" is the opposite of "Modal". It would be wrong to put "vbModeless" if you mean "vbModal" (or vice versa)

quote:
Originally posted by Matty
(...) And 1 is vbModal, showing ontop of all other windows.
Although it indeed shows on top of other windows, that isn't exactly the true meaning of it.

Modal vs. Modeless:
The definition of a modal form is that it must be closed (hidden or unloaded) before you can continue working with the rest of the application (hence it is also shown on top; but this is rather a "side effect" so to speak). For example, a dialog box is modal if it requires you to click OK or Cancel before you can switch to another form or dialog box.

Modeless dialog boxes let you shift the focus between the dialog box and another form without having to close the dialog box. You can continue to work elsewhere in the current application while the dialog box is displayed. Modeless dialog boxes are rare. From the Edit menu, the Find dialog box in Visual Basic is an example of a modeless dialog box.
(snipped taken from the MSDN library)

;)

----------------------

From the MSDN Library:
PRB: Modeless Forms in VB ActiveX DLL's Don't Display in VC++ Clients
INFO: Non-Modal Form Support in Visual Basic DLLs

----------------------

did I ever mention you can find everything on the MSDN library? (a) No? hmmm... well... you can find everything on the MSDN library :p)
RE: [VB6] vbModeless? by matty on 10-10-2005 at 11:46 PM

quote:
Originally posted by CookieRevised
Although it indeed shows on top of other windows, that isn't exactly the true meaning of it.
Showing ontop of all windows in your application making them inaccessible until you close the window... hows that Cook?
RE: [VB6] vbModeless? by CookieRevised on 10-11-2005 at 02:11 AM

quote:
Originally posted by Matty
Showing ontop of all windows in your application making themthe other forms inaccessible until you close the window... hows that Cook?
hehehe :p, yep, correct (y)
RE: [VB6] vbModeless? by eSouL on 10-28-2005 at 07:14 AM

Hi,

I discovered an odd behaviour when using this method to show a modeless form. Whenever you use the form (writing some text into a textbox, clicking a button etc.), the form does not appear to be activated, if you look at the taskbar!

What i mean is, the form's window in the taskbar will not get highlighted as the 'active' window, when it is indeed in the foreground. The highlight will remain at the last activated app, no matter how hard you click or drag the new vb form. The only way to get it highlighted is to actually click on the form window in the taskbar.

This normally wouldn't be a problem, but right now I'm using FlashWindowEx to flash the form taskbar window on some event and will continue to flash until user activates the form (dwFlags = FLASHW_TRAY | FLASHW_TIMERNOFG). But the form flashing will NOT stop even after I click on the vb form and start interacting with it, simple because somehow Windows thinks it is still not the active app.

Any ideas?


RE: [VB6] vbModeless? by CookieRevised on 10-28-2005 at 05:17 PM

There nothing odd about it though...

Making a form modeless doesn't mean it is activated. In fact it is not and that's very normal. Activating a form and making a form modeless or modal are two different things... A form (aka dialog) can even be at the foreground but not activated.

All these window states are independant and must be set seperatly and shouldn't be taken as "granted" (although some states automatically activate another by default, eg: making a form modal will also activate it and make it the foreground window).


RE: [VB6] vbModeless? by eSouL on 10-28-2005 at 07:53 PM

Cookie, when I use the exact same code in a normal exe project to call up a new form, the bahaviour was everything as expected, ie. you click the form, it gets its focus and becomes highlighted in the taskbar. But when the same piece of code is used in a plugin dll to call up new forms, these forms don't appear as highlighted in the taskbar. I tested on the vanilla sample plugin.


RE: [VB6] vbModeless? by matty on 10-28-2005 at 08:00 PM

Why not use the BringWindowToTop API function. Or SetForeGround API Function.

Public Declare Function BringWindowToTop Lib "user32" Alias "BringWindowToTop" (ByVal hwnd As Long) As Long
Public Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long


RE: [VB6] vbModeless? by CookieRevised on 10-29-2005 at 01:54 AM

quote:
Originally posted by eSouL
Cookie, when I use the exact same code in a normal exe project to call up a new form, the bahaviour was everything as expected, ie. you click the form, it gets its focus and becomes highlighted in the taskbar. But when the same piece of code is used in a plugin dll to call up new forms, these forms don't appear as highlighted in the taskbar. I tested on the vanilla sample plugin.
As said before, it depends on the environment you're in as all those states are not automatically linked to eachother (in a stand alone app it just seems that way because there are no other threads for the same process for example).

Look at the pages from the MSDN Library I listed in my first post.