Moving an application!

muzamilsumra
02-23-2008, 04:19 AM
Hello Ppl..
Can someone please help me on this...
how can you move an external app around the screen using visual basic 6??

for example we can open the calculator either using the shell command or the createprocess api...but what if i want to open calculator and the move it to may be say x coordinate 0 and y coordinate 0 which would move the calculator to the top left of the screen...Any help would be appreciated...

Thx all.

DougT
02-23-2008, 04:52 AM
Well, you could use FindWindow to locate it's handle and SetWindowPos to reposition it, or if you use CreateProcess, you can set its x and y location in the STARTUP structure.

muzamilsumra
02-23-2008, 10:19 AM
hey can u show me how if you dont mind?

seantheduke
02-23-2008, 10:34 AM
http://allapi.mentalis.org/apilist/FindWindow.shtml

http://allapi.mentalis.org/apilist/SetWindowPos.shtml



Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long



poo = FindWindow (lpClassName, lpWindowName)
SetWindowPos poo, HWND_MOST, _, _, _, _, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE


something like that i think but im a noob. play around iwth it and u'll get it

muzamilsumra
02-23-2008, 12:45 PM
srry guys i still cant get thru this!! please guys can u give me more detals..plz plz plz!! :confused:

i tried doing this but i the calculator opens at differnet positions..

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long


Private Sub Command1_Click()
SetWindowPos Shell("calc.exe"), HWND_TOPMOST, 0, 0, 1000, 500, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End Sub

muzamilsumra
02-24-2008, 12:41 AM
please, can some1 help me oput here!

JoeCooper
02-24-2008, 06:40 AM
im sure i posted on this forum before, but seems to of got deleted? was going to give you the full code aswell

muzamilsumra
02-24-2008, 09:00 AM
hey joe..yeah u hadtold me something b4 and i had asked u sumthing too...but after sometime when i checked back...the posts were deleted i dont knw how and y!! can u give me the full code please???

lebb
02-25-2008, 05:32 AM
Joe/muzamilsumra: Please review our rules. We don't allow code handouts (nor requests for such), although you are welcome to post explanations and suggestions.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum