What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » Showing Form without vbModal in VB? For the programmers out there... :D

Showing Form without vbModal in VB? For the programmers out there... :D
Author: Message:
(CyBeRDuDe)
Senior Member
****


Posts: 512
Reputation: 21
37 / Male / –
Joined: Jul 2003
O.P. Huh?  Showing Form without vbModal in VB? For the programmers out there... :D
Is it possible in a MsgPlus! Plugin to show a form without using the vbModal arguement, since it puts Messenger "on hold"... I need to show a form without holding back on Messenger....
And NOT open a instance of a seperate exe file...
I think I read somewhere that you could create a seperate activex .dll file and just load that?`.. How would I do that?...
Or should I use the CreateWindow API and some various other API's?.... Would you adivse to use the CreateWindow API to create a form in runtime?... Or not?.. I've read it should be very though to make it good, and that is was sometimes unstable... Is that true?...
How would you do it?

Please Help me!?....
05-20-2005 08:00 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Showing Form without vbModal in VB? For the programmers out there... :D
code:
Public Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

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

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Const SW_SHOW = 5
Public Const SW_HIDE = 0
Public Const WM_CLOSE = &H10

'Usage: Show Window
     ShowWindow Form1.hWnd, SW_SHOW

'Usage: Hide Window
     ShowWindow Form1.hWnd, SW_HIDE

'Usage: Close Window #1
     SendMessage Form1.hWnd, 0&, 0&, WM_CLOSE

'Usage: Close Window #2
     DestroyWindow Form1.hWnd


Hope that helps.
They all go into a module. Change them from Public to Private if you want to just put them in the Class.

This post was edited on 05-21-2005 at 04:19 AM by matty.
05-21-2005 04:05 AM
Profile E-Mail PM Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
31 / Male / Flag
Joined: Mar 2003
Status: Online
RE: Showing Form without vbModal in VB? For the programmers out there... :D
quote:
Originally posted by Matty
Form1.hWnd
If you want to get the hwnd of a form, doesn't it need to be shown? :S

What I would do, is to enum all the windows, and use the EnableWindow API on msn's windows hWnds...

Did you try the above...?
YouTube closed-captions ripper (also allows you to download videos!)
05-21-2005 11:46 AM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Showing Form without vbModal in VB? For the programmers out there... :D
quote:
Originally posted by Mike2
quote:
Originally posted by Matty
Form1.hWnd
If you want to get the hwnd of a form, doesn't it need to be shown? :S
No, it must simply exist (aka loaded in memory), and in VB a created form in your project always exist...

quote:
Originally posted by Mike2
What I would do, is to enum all the windows, and use the EnableWindow API on msn's windows hWnds...
Cyberdude isn't talking about MSN Messenger windows.
.-= A 'frrrrrrrituurrr' for Wacky =-.
05-21-2005 01:11 PM
Profile PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Showing Form without vbModal in VB? For the programmers out there... :D
quote:
Originally posted by CookieRevised
in VB a created form in your project always exist...
You sure? I would have thought the form was loaded on the first .Show line.
I suppose if that's the case, you can use 'Load Form1'. Probably wouldn't make any difference whether the form was loaded or not when that line is executed: it just makes certain.
[Image: spartaafk.png]
05-21-2005 01:56 PM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: Showing Form without vbModal in VB? For the programmers out there... :D
quote:
Originally posted by raceprouk
quote:
Originally posted by CookieRevised
in VB a created form in your project always exist...
You sure?
yes... although I maybe didn't explained it well...

quote:
Originally posted by raceprouk
I would have thought the form was loaded on the first .Show line.
The normal command for loading a form is "Load", but this will not show the form yet.

The "Show" method itself, also automatically loads the form if it wasn't loaded already and then shows the form. This is the same as its counterpart method "Hide", it also automatically loads the form if it wasn't loaded already and then hides the form.

But a form is not only automatically loaded when used with methods or commands, it is also loads automatically whenever you use a property of the form itself, hence when using .hWnd the forms gets loaded.

quote:
Originally posted by raceprouk
I suppose if that's the case, you can use 'Load Form1'. Probably wouldn't make any difference whether the form was loaded or not when that line is executed: it just makes certain.
in this case, yep.


you can check this yourself:
code:
'To make sure the form is "unloaded":
Unload Form1

'show the handle
MsgBox Form1.hWnd
You'll see it is a valid handle again because the form was loaded again


But note that DestroyWindow will effectivly destroy the form in memory!! After DestroyWindow you wont be able to show the form again; it's like it never existed, everything will be cleared. Hence I said in my first reply to this thread that a form always exists in memory in VB.

This post was edited on 05-21-2005 at 03:13 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
05-21-2005 02:47 PM
Profile PM Find Quote Report
(CyBeRDuDe)
Senior Member
****


Posts: 512
Reputation: 21
37 / Male / –
Joined: Jul 2003
O.P. RE: Showing Form without vbModal in VB? For the programmers out there... :D
quote:
Originally posted by Matty
code:
Public Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

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

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Const SW_SHOW = 5
Public Const SW_HIDE = 0
Public Const WM_CLOSE = &H10

'Usage: Show Window
     ShowWindow Form1.hWnd, SW_SHOW

'Usage: Hide Window
     ShowWindow Form1.hWnd, SW_HIDE

'Usage: Close Window #1
     SendMessage Form1.hWnd, 0&, 0&, WM_CLOSE

'Usage: Close Window #2
     DestroyWindow Form1.hWnd


Hope that helps.
They all go into a module. Change them from Public to Private if you want to just put them in the Class.
This is SO NICE!!! :D..
Works perfectly.. Well.. At least until now.. :D..
Well.. I have some problems with my odl code.. just need to rewrite eveyrthing I think... But thanks.... I just didn't think you could use the ShowWindow api like that.. but It works brilliant, showing forms without putting Messenger on hold... Nice matty... :D..
Well.. I gues thread is kinda closed now.. :D..
05-21-2005 02:50 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Showing Form without vbModal in VB? For the programmers out there... :D
quote:
Originally posted by (CyBeRDuDe)
I just didn't think you could use the ShowWindow api like that
You can do even a lot more with it ;)


'Hides the window and activates another window.
Public Const SW_HIDE = 0

'Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
Public Const SW_SHOWNORMAL = 1

'Activates the window and displays it as a minimized window.
Public Const SW_SHOWMINIMIZED = 2

'Activates the window and displays it as a maximized window.
Public Const SW_SHOWMAXIMIZED = 3

'Displays a window in its most recent size and position. The active window remains active.
Public Const SW_SHOWNOACTIVATE = 4

'Activates the window and displays it in its current size and position.
Public Const SW_SHOW = 5

'Minimizes the specified window and activates the next top-level window in the Z order.
Public Const SW_MINIMIZE = 6

'Displays the window as a minimized window. The active window remains active.
Public Const SW_SHOWMINNOACTIVE = 7

'Displays the window in its current state. The active window remains active.
Public Const SW_SHOWNA = 8

'Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when restoring a minimized window.
Public Const SW_RESTORE = 9

'Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application.
Public Const SW_SHOWDEFAULT = 10

This post was edited on 05-21-2005 at 03:24 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
05-21-2005 03:10 PM
Profile PM Find Quote Report
DeVill
New Member
*

Avatar

Posts: 5
43 / Male / –
Joined: Jul 2005
RE: Showing Form without vbModal in VB? For the programmers out there... :D
That's grate! But I have problem with this one... I have a tag with:

code:
        sResult = "Okay1"
        ShowWindow Form1.hwnd, SW_SHOW
        do
                DoEvents
        loop until Allow
        ParseCommand = True
        Exit Function


Allow is a global boolean! Now the command desapeares, and Okay1 is displayed, but message is not sent... first I thought it hade something to do with DoEvents, but that's not the case, if I remove the line with ShowWindow, than it works!

This post was edited on 07-03-2005 at 03:49 PM by DeVill.
07-03-2005 12:20 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On