WebSite Information > Article Discussions
Asking OS/2 things to OpenAI - Fun and maybe Insightful.
RTAN:
That’s interesting, I use ChatGPT quite a lot, especially for info on old OS’s like OS/2. For example I recently had quite a lengthy conversation about it regarding old networking protocols such as NetBIOS. When you install OS/2 Warp Connect you can choose from protocols such as TCP/IP, NetBIOS, and NetBIOS over TCP/IP. I was trying to understand the difference between vanilla NetBIOS and NetBIOS over TCP/IP.
And that took me off on a tangent about NetBEUI since that’s what’s available natively with Windows for Workgroups 3.11.
You are absolutely right Martin that it’s very important to double check answers and challenge ChatGPT quite frequently. It gets things wrong fairly often, such as thinking that OS/2 2.0 was available on CD-ROM (it wasn’t, except for a very limited pre-release). But, to its credit, when challenged it will go away and think about it, then come back with a correction that’s normally closer to the truth.
Perhaps this would be a good time to resurrect the phrase: trust, but verify. ;)
Martin Iturbide:
Hello
Yes, it is interesting as a tool and it is always required to check it out the response.
For me it is like the marketing guy that you need to review his stuff before publishing what he says. ;D
But for me it is interesting tool that can give you some inspiration and ideas. Good for brainstorming.
Regards
Martin Iturbide:
OK. It is now time to get crazy.
I used NotebookLM from Google - https://notebooklm.google.com
I uploaded the PDF of "1988 - Inside OS2 - Gordon Letwin" and it has an option at the right to create some kind of a podcast about that content. (Deep Dive conversation)
It created a 50MB, 20 minutes wav file. Crazy.
- https://drive.google.com/file/d/1CvGsp03V6MLTn64B2xdJzSwH83OFbatM/view?usp=sharing
Martin Iturbide:
With the same tool, I asked "Give me a C source code sample of creating a window in PM"
--- Quote ---The sources offer several examples of creating windows in OS/2 Presentation Manager using the WinCreateWindow and WinCreateStdWindow functions. Here's a C source code sample based on these examples, along with explanations:
#define INCL_WIN // Include header file for PM window functions
#include <os2.h>
// Client window procedure - handles messages for the window
MRESULT EXPENTRY ClientWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) {
switch (msg) {
case WM_PAINT:
// Handle window painting - draw content here
break;
case WM_DESTROY:
// Handle window destruction
break;
default:
return WinDefWindowProc(hwnd, msg, mp1, mp2); // Default message processing
}
return NULL;
}
int main() {
HAB hab; // Anchor block handle
HMQ hmq; // Message queue handle
HWND hwndFrame; // Frame window handle
HWND hwndClient; // Client window handle
QMSG qmsg; // Message queue element
ULONG flCreateFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
FCF_MINMAX | FCF_SHELLPOSITION | FCF_TASKLIST;
static CHAR szClientClass[] = "Client Window"; // Client window class name
hab = WinInitialize(NULL); // Initialize PM
hmq = WinCreateMsgQueue(hab, 0); // Create message queue
// Register client window class
WinRegisterClass(hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0);
// Create standard window
hwndFrame = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE, &flCreateFlags,
szClientClass, "My Window", 0L, NULL, 0, &hwndClient);
// Message dispatch loop
while (WinGetMsg(hab, &qmsg, NULL, 0, 0)) {
WinDispatchMsg(hab, &qmsg);
}
WinDestroyWindow(hwndFrame); // Destroy window
WinDestroyMsgQueue(hmq); // Destroy message queue
WinTerminate(hab); // Terminate PM
return 0;
}
Explanation:
●
Headers: INCL_WIN is defined to include the necessary header file (pmwin.h) for PM window functions. os2.h is included for general OS/2 API definitions.
●
Client Window Procedure: ClientWndProc is responsible for handling messages sent to the window. It's crucial for responding to events like painting and window destruction. The WinDefWindowProc function is used to process default messages.
●
Main Function:
○
Initialization: WinInitialize and WinCreateMsgQueue initialize the Presentation Manager and create a message queue.
○
Window Class Registration: WinRegisterClass associates the client window procedure (ClientWndProc) with a window class name (szClientClass).
○
Window Creation: WinCreateStdWindow creates a standard window with a title bar, system menu, and other standard elements. The flCreateFlags variable controls the window's style and appearance.
○
Message Loop: The while loop retrieves messages from the message queue using WinGetMsg and dispatches them to the appropriate window procedure using WinDispatchMsg. This is the core of the event-driven model in PM.
○
Cleanup: WinDestroyWindow, WinDestroyMsgQueue, and WinTerminate clean up resources and exit the PM environment.
Key Points:
●
The code creates a standard window, which provides the basic framework for most PM applications.
●
You can customize the window's appearance using the flCreateFlags variable and its style constants.
●
The client window procedure is where you'll handle window-specific logic, including drawing content and responding to user interactions.
●
Understanding the message loop and how PM handles events is crucial for developing OS/2 applications.
Remember that this is a basic example, and building more complex applications would involve using additional PM API functions to create and manage other UI elements like menus, dialog boxes, and controls.
--- End quote ---
Dave Yeo:
Thought I'd ask Gemini a similar question. Larger example, includes where the example came from, missing #define INCL_WIN.
Actually, looking at the source, it is old MS Programming library v1.3, 16 bit API?
--- Code: ---#include <os2.h>
/* Window class structure */
static HAB hab;
static HWND hwndFrame;
/* Window procedure */
MRESULT EXPENTRY ClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
switch (msg) {
case WM_PAINT: {
HPS hps;
RECTL rc;
WinQueryWindowRect(hwnd, &rc);
hps = WinGetPS(hwnd);
GpiSetColor(hps, SYSCLR_BLUE);
GpiFillRect(hps, &rc);
WinReleasePS(hps);
break;
}
case WM_DESTROY:
WinPostMsg(hwndFrame, WM_QUIT, 0, 0);
break;
default:
return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
return 0;
}
/* Frame window procedure */
MRESULT EXPENTRY FrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
switch (msg) {
case WM_COMMAND:
switch (SHORT1FROMMP(mp1)) {
case IDM_QUIT:
WinPostMsg(hwnd, WM_CLOSE, 0, 0);
break;
}
break;
case WM_CLOSE:
WinDestroyWindow(hwnd);
break;
default:
return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
return 0;
}
int main(VOID) {
HAB hab;
HMQ hmq;
HWND hwndFrame, hwndClient;
QMSG qmsg;
/* Initialize Presentation Manager */
hab = WinInitialize(0);
hmq = WinCreateMsgQueue(hab, 0);
/* Register window classes */
WinRegisterClass(hab, "MyClientClass", ClientWndProc, CS_SIZEREDRAW, 0);
WinRegisterClass(hab, "MyFrameClass", FrameWndProc, CS_SIZEREDRAW, 0);
/* Create frame window */
hwndFrame = WinCreateWindow(
HWND_DESKTOP,
"My Frame Window",
"MyFrameClass",
WS_VISIBLE | WS_BORDER | FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX,
0, 0, 200, 100,
HWND_DESKTOP,
HWND_TOP,
hab,
NULL,
NULL
);
/* Create client window */
hwndClient = WinCreateWindow(
hwndFrame,
"My Client Window",
"MyClientClass",
WS_VISIBLE,
0, 0, 200, 100,
hwndFrame,
HWND_TOP,
hab,
NULL,
NULL
);
/* Message loop */
while (WinGetMsg(hab, &qmsg, NULL, 0, 0)) {
WinDispatchMsg(hab, &qmsg);
}
/* Clean up */
WinDestroyWindow(hwndFrame);
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
return 0;
}
Explanation:
Include Header:
#include <os2.h>: Includes the necessary header file for OS/2 Presentation Manager functions.
Global Variables:
hab: An anchor block handle, used to identify the application to Presentation Manager.
hwndFrame: A handle to the frame window.
Window Procedures:
ClientWndProc: Handles messages for the client window.
WM_PAINT: Fills the client area with blue color.
WM_DESTROY: Posts a quit message to the frame window.
FrameWndProc: Handles messages for the frame window.
WM_COMMAND: Processes menu commands (not implemented in this example).
WM_CLOSE: Destroys the frame window.
Main Function:
Initialization:
WinInitialize: Initializes Presentation Manager and returns an anchor block handle.
WinCreateMsgQueue: Creates a message queue for the application.
Window Registration:
WinRegisterClass: Registers the window classes for the client and frame windows.
Window Creation:
WinCreateWindow: Creates the frame and client windows with the specified attributes.
Message Loop:
WinGetMsg: Retrieves messages from the message queue.
WinDispatchMsg: Dispatches messages to the appropriate window procedures.
Cleanup:
WinDestroyWindow: Destroys the frame window.
WinDestroyMsgQueue: Destroys the message queue.
WinTerminate: Terminates Presentation Manager.
Note:
This is a basic example and can be extended to include more features such as menus, controls, and more complex window interactions.
You'll need to use an OS/2 development environment (such as IBM Visual Age for C++) to compile and run this code.
This code demonstrates the fundamental concepts of creating and managing windows in the OS/2 Presentation Manager environment.
This example provides a starting point for creating OS/2 Presentation Manager applications. You can further explore the Presentation Manager API to implement more advanced features and create sophisticated graphical user interfaces.
https://github.com/spacerace/MPL
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version