|
Post by tsh73 on Sept 28, 2021 12:36:44 GMT -5
Brandon, thanks I completely forgot the "!" As for handle$ not working - I don't care until it does
|
|
|
Post by Rod on Sept 28, 2021 13:14:39 GMT -5
I think we have misread the question. The mainwin is essentially a debugging window that opens in the background whenever a program is run unless you have issued a nomainwin command.
Others have responded showing you how to position other types of window and controls. You will find the mainwin a bit cluncky as it has not got much functionality built in. You can change the number of col and rows but not much else.
A lot of folks use it as a console style control but it has its limitations. The normal approach in Liberty is to open appropriate windows and controls for your application.
It may be possible to move the mainwin with API but I can't recall seeing code. You would need to get its handle and use the movewindow routine on it. Perhaps others have seen this done.
|
|
|
Post by Rod on Sept 28, 2021 13:22:52 GMT -5
Ok, try this, I think it works because mainwin will be the active window on launch. The typing has to be wrong though it works for me. Handles are usually best typed as ulong.
calldll #user32,"GetActiveWindow",_ mainwinhandle as ulong calldll #user32,"MoveWindow", _ mainwinhandle as ulong, _ 400 as short, _ 200 as short, _ 600 as short, _ 600 as short, _ 1 as word, _ result as long
wait
|
|
|
Post by tsh73 on Sept 28, 2021 13:34:12 GMT -5
|
|
|
Post by Rod on Sept 28, 2021 14:12:35 GMT -5
Yeah short should probably be long and the last result works with void or long. An api guru would need to tell us what is safest.
|
|
|
Post by Walt Decker on Sept 28, 2021 15:24:54 GMT -5
On movewindow() the specs indicate all parameters as int except bRepaint which is boolean; however short or long will work for all parameters including the return value which is boolean. The return value is actually optional so if you are not concerned about that it can be void.
|
|
|
Post by Brandon Parker on Sept 28, 2021 15:56:58 GMT -5
Normally, the MainWin is used for debugging purposes or the simple output of a program. To move the MainWin, you will first have to find the handle to it since it is not exposed through LB.
If you are just running code through the LB IDE, you can simply use the code posted below, but if you want to move the MainWin when the code is compiled to a TKN file, you would need to get the path of the TKN file. Here is a method that takes care of both situations...
I would really suggest building your own output window though since the MainWin is quite limited in its functionality with standard LB code.
'Code produced by Brandon R. Parker; September 2021 Struct rect, left As long, _ top As long, _ right As long, _ bottom As long
isRunningInIDE$ = getIDEFileName$() If (isRunningInIDE$ = "") Then isRunningInIDE$ = buildTKNPathAndName$(GetModuleFileName$())
myMainWin = FindWindow("Program named - '";isRunningInIDE$;"'") result = GetWindowRect(myMainWin) result = MoveWindow(myMainWin, 1, 1, Abs(Abs(rect.right.struct) - Abs(rect.left.struct)), Abs(Abs(rect.bottom.struct) - Abs(rect.top.struct)), 1) Wait
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function getIDEFileName$() On Error GoTo [Error] getIDEFileName$ = IDEFileName$() [Error] End Function
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function GetWindowRect(hWnd) 'Get WindwRectangle CallDLL #user32, "GetWindowRect", hWnd As ulong, _ rect As struct, _ GetWindowRect As ulong End Function
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function FindWindow(lpWindowName$) lpWindowName$ = lpWindowName$ + chr$(0) CallDLL #user32, "FindWindowA", _NULL As ulong, _ lpWindowName$ As ptr, _ FindWindow As ulong End Function
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function MoveWindow(hWnd, winX, winY, wWidth, wHeight, bRepaint) CallDLL #user32, "MoveWindow", hWnd As ulong, _ winX As long, _ winY As long, _ wWidth As long, _ wHeight As long, _ bRepaint As long, _ MoveWindow As long End Function
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function GetModuleFileName$() GetModuleFileName$ = space$(_MAX_PATH) + chr$(0) CallDLL #kernel32, "GetModuleFileNameA", _NULL As ulong,_ GetModuleFileName$ As ptr,_ _MAX_PATH As long,_ result As long
GetModuleFileName$ = trim$(GetModuleFileName$) End Function
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function buildTKNPathAndName$(EXEPathAndName$) buildTKNPathAndName$ = UpTo$(EXEPathAndName$, ".exe");".tkn" End Function
{:0)
Brandon Parker
|
|
zpq
New Member
Posts: 18
|
Post by zpq on Sept 30, 2021 8:42:23 GMT -5
Hi Thanks to everyone for your input.
|
|