API for OpenWindow()?
API for OpenWindow()?
Hello!
I am looking for the API of OpenWindow, I mean sure it's maybe done with CreateWindowEx_(), but how does the procedure look and without CallBack?
CodeArchiv showed me some good codes on how to use CreateWindowEX_(), but all used CallBacks...
So I want the procedure for OpenWindow, trying now 2 days with no luck.
I need also help with the WNDCLASSEX class, is it possible to have a window without this class?
Please help, thanks!
I am looking for the API of OpenWindow, I mean sure it's maybe done with CreateWindowEx_(), but how does the procedure look and without CallBack?
CodeArchiv showed me some good codes on how to use CreateWindowEX_(), but all used CallBacks...
So I want the procedure for OpenWindow, trying now 2 days with no luck.
I need also help with the WNDCLASSEX class, is it possible to have a window without this class?
Please help, thanks!
There is no OpenWindow() API function. You have to use CreateWindow_() or CreateWindowEX_().
Both of these API functions require that you first register a window class (or use a predefined one such as "edit" for an edit control etc.) and a window class has to have an associated callback function which all windows belonging to the class will use. Without the callback, messages will not get processed and your window will be about as much use as a brick made of paper!
So, I'm afraid if you're relying upon the API, then there is no escaping CreateWindowEx_(), no escaping window classes, and no escaping callbacks!
Both of these API functions require that you first register a window class (or use a predefined one such as "edit" for an edit control etc.) and a window class has to have an associated callback function which all windows belonging to the class will use. Without the callback, messages will not get processed and your window will be about as much use as a brick made of paper!
So, I'm afraid if you're relying upon the API, then there is no escaping CreateWindowEx_(), no escaping window classes, and no escaping callbacks!

I may look like a mule, but I'm not a complete ass.
It's impossible to create a main application window with CreateWindow_() / CreateWindowEx_() and use native PB commands against it. Sorry. You're going to get into some advanced code if you start to create your own windows and handle messages. I have some code here on doing this - mine was in order to create a unicode capable window via CreateWindowExW_() and I had to handle a lot. Search for my nickname and the word 'unicode' and you should see it.
Otherwise, yeah, it's impossible. From what I understand, there are many things that PB does internally and it has it's own way of handling it's own windows. fred or freak or other gurus, please correct me if I'm wrong here.
Otherwise, yeah, it's impossible. From what I understand, there are many things that PB does internally and it has it's own way of handling it's own windows. fred or freak or other gurus, please correct me if I'm wrong here.
Hey people. you all got me wrong. damn
I wanted to have a procedure that works just like PB's OpenWindow, but in API.
Just like using MessageBox_() instead of MessageRequester(), or Sleep_() instead of Delay().
BTW: PB doesn't support CreateWindow_()? It doesn't recognize it, always tells me that CreateWindow_() is not a function array or a linked list?
This is crazy, how do you translate PB's OpenWindow to API?
Please translate this for me into API:
Thanks mates!
I hope you now got me 

I wanted to have a procedure that works just like PB's OpenWindow, but in API.
Just like using MessageBox_() instead of MessageRequester(), or Sleep_() instead of Delay().
BTW: PB doesn't support CreateWindow_()? It doesn't recognize it, always tells me that CreateWindow_() is not a function array or a linked list?
This is crazy, how do you translate PB's OpenWindow to API?
Please translate this for me into API:
Code: Select all
OpenWindow(0, 0, 0, 300, 300, #PB_Window_SystemMenu, "Test?")


This is used rather than the normal 'CreateWindow_(..' because with this you dont need the normal version.Henrik wrote:Hi
Try CreateWindowEx_(......
Best Henrik
Mixing API and native PB code is simple, you just have to know API in order to correctly handle events in the callback.
Here is a simple bit of code i have in my bits box here:
Code: Select all
;===========================================================================
;-PROCEDURES
;===========================================================================
;Window callback
Procedure WindowCallback(hWnd, Message, wParam, lParam)
Debug Message
Select Message
Case #WM_CLOSE
UnregisterClass_("WindowClass", GetModuleHandle_(#Null))
DestroyWindow_(hWnd)
ProcedureReturn 0
Case #WM_DESTROY
UnregisterClass_("WindowClass", GetModuleHandle_(#Null))
PostQuitMessage_(0)
ProcedureReturn 0
EndSelect
Result = DefWindowProc_(hWnd, Message, wParam, lParam)
ProcedureReturn Result
EndProcedure
;Window class
WindowClass.WNDCLASS
WindowClass\style = #CS_HREDRAW | #CS_VREDRAW
WindowClass\lpfnWndProc = @WindowCallback()
WindowClass\cbClsExtra = 0
WindowClass\cbWndExtra = 0
WindowClass\hInstance = GetModuleHandle_(#Null)
WindowClass\hIcon = LoadIcon_(#Null, #IDI_APPLICATION)
WindowClass\hCursor = LoadCursor_(#Null, #IDC_ARROW)
WindowClass\hbrBackground = GetStockObject_(#WHITE_BRUSH)
WindowClass\lpszMenuName = #Null
WindowClass\lpszClassName = @"WindowClass"
RegisterClass_(WindowClass)
;===========================================================================
;-GEOMETRY
;===========================================================================
;Calculate the window position to display it centrally
ScreenWidth.l = GetSystemMetrics_(#SM_CXSCREEN)
ScreenHeight.l = GetSystemMetrics_(#SM_CYSCREEN)
WindowWidth.l = 400
WindowHeight.l = 300
WindowXPosition.l = (ScreenWidth / 2) - (WindowWidth / 2)
WindowYPosition.l = (ScreenHeight/ 2) - (WindowHeight/ 2)
;Open a window
hWnd.l = CreateWindowEx_(0, "WindowClass", "Hello World", #WS_VISIBLE | #WS_OVERLAPPEDWINDOW | #WS_SIZEBOX , WindowXPosition, WindowYPosition, WindowWidth, WindowHeight, 0, 0, GetModuleHandle_(#Null), 0)
CreateGadgetList(hWnd)
ButtonGadget(1, 10, 10, 100, 21, "Close")
;===========================================================================
;-MAIN LOOP
;===========================================================================
If hWnd
While GetMessage_(Message.MSG, 0, 0, 0)
TranslateMessage_(Message)
DispatchMessage_(Message)
Wend
EndIf

I also mixed the two in this screensaver:
http://www.garyw.uklinux.net/pb/Screens ... Source.zip
see the 'ExecutePreview()' procedure.