OS/2, eCS & ArcaOS - Technical > Programming

Manipulating a PM window from another program

(1/3) > >>

Martin Vieregg:
For my commandline frontend, I need to manipulate the VIO window where cmd.exe runs. I have got the window handle. I want to remove buttons in the window title, because the user should neither close the window, nor minimize or maximize. I assume I have to use a WinSetWindow* call and I can use the constant  WS_MAXIMIZEBOX for example. But I did not find any documentation, I only found one for Windows in the Internet. Any hints are appreciated.

Mathias:
Unfortunately I cannot help on topic, but a side note: Please keep the shortcuts (close, minimise, maximise) in mind. Removing the buttons alone might not be enough.
I'm not that far into developing on OS/2 to know, but could be that if the buttons are gone, the shortcuts won't work either? - Not sure. - Just as a reminder..

Laurence Pithie:
To disable a window use the WinEnableWindow call with the handle of the window you wish to disable as the first parameter and FALSE as the second parametert. To get the window handle of the control windows use WinWindowFromID with the Frame window handle as the first parameter and the window id of the control window as the second parameter. So to disable and hide the minimize and maximize control window you would use

--- Code: ---hwnd = WinWindowFromID(hwndParent, FID_MINMAX);
WinEnableWindow(hwnd, FALSE);
WinShowWindow(hwnd, FALSE);

--- End code ---
The identifier for the system menu is FID_SYSMENU.
To remove the windows instead of disabling and hiding them then call WinDestroyWindow.
However, given that the VIO window has standard input and standard output redirected(If you're interested in stderror you could redirect that as well) it's not really going to be showing anything of interest so it would be simpler to simply hide the entire window. To prevent the user from closing it from the window list you'd need to get the Switch entry handle for the window and then remove it from the switch list using WinQuerySwitchHandle and WinRemoveSwitchEntry.


Pete:
Hi Martin

Possibly a parameter in DosStartSession - looking at the example in cp1.inf (os2 toolkit) I see the following within the example given :-

        /* Open the session VISIBLE and MAXIMIZED */
   SData.PgmControl = SSF_CONTROL_VISIBLE | SSF_CONTROL_MAXIMIZE;


Regards

Pete

Martin Vieregg:

--- Quote ---SData.PgmControl = SSF_CONTROL_VISIBLE | SSF_CONTROL_MAXIMIZE;
--- End quote ---

PgmControl defines the window state when starting the window with DosStartSession. It would be started visible and maximized in this case. I want to manipulate the "maximize" button in the title bar. Laurence is right. I remember now that long time ago I already programmed it for my 4allCalc calulator, but meanwhile I do not practise regulary OS/2 API programming anymore. Any button has got a window handle, and with this window handle, you can do all the things you want.

Laurences code principally works, but WinEnableWindow FALSE makes the buttons non-functional, but they are normally shown. WinShowWindow FALSE deletes the buttons, but now there's a "hole" which is no more redrawn. The titlebar width is unchanged. The first trial, I made a programming failure and it did not work. I have to recalulate the correct width of the titlebar so it "fits" the holes. The correct titlebar width is the client width minus the width of the sysmenu button. This code works:


--- Code: ---hw = WinWindowFromID(VIOhandle, FID_MINMAX);
WinEnableWindow(hw, FALSE); //turns off Min/Max functionality, but buttons are still shown
WinShowWindow(hw, FALSE); //do not show Min/Max buttons
//enlarge the titlebar width to fit the "holes"
hwtb = WinWindowFromID(VIOhandle, FID_TITLEBAR); WinQueryWindowPos (hw, &swp);
tbHeight = swp.cy;
hw = WinWindowFromID(VIOhandle, FID_CLIENT); WinQueryWindowPos (hw, &swp);
clWidth = swp.cx;
hw = WinWindowFromID(VIOhandle, FID_SYSMENU); WinQueryWindowPos (hw, &swp);
sysWidth = swp.cx;
ZOrderHWND = 0;
vLeft = 0; vBottom = 0; flOptions = SWP_SIZE;
WinSetWindowPos (hwtb, 0, vLeft, vBottom, clWidth-sysWidth, tbHeight, flOptions);

--- End code ---

Because I need the System Menu of the VIO window, I cannot delete the System Menu and the user has got access to CLOSE which I do not want. Is it possible to disable the close functionality (also in the switch list) ? If not, I will restart the session automatically.

Navigation

[0] Message Index

[#] Next page

Go to full version