GUI app and winAPI calls - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7) +---- Thread: GUI app and winAPI calls (/showthread.php?tid=1568) |
GUI app and winAPI calls - aurel - 03-22-2023 Usual VB method is : Declare Function CreateWindowEx Lib "user32.dll" Alias "CreateWindowExA"(ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, ByRef lpParam As Long) As Long but what i found is awkward way with : FUNCTION CreateWindowExA%& (BYVAL dwExStyle~&, BYVAL lpClassName%&, BYVAL lpWindowName%&, BYVAL dwStyle~&, BYVAL x&, BYVAL y&, BYVAL nWidth&, BYVAL nHeight&, BYVAL hWndParent%&, BYVAL hMenu%&, BYVAL hInstance%&, BYVAL lpParam%&) I will try reconstruct this ... RE: GUI app and winAPI calls - SpriggsySpriggs - 03-22-2023 Here is the declaration I use and it works great: Code: (Select All) Declare CustomType Library You really only need to use the "A" suffix when calling directly from the DLL. If you use the header files instead, Windows will automatically select the "A" version. So you won't need CreateWindowExA in my declaration but you would if you pulled it from the DLL. RE: GUI app and winAPI calls - aurel - 03-22-2023 Hi Zak Thanks ..but that is not only problem , ihave problem with _OFFSET so my question is why is Code: (Select All) Byval lpClassName As Offset, Byval lpWindowName As Offset and also why is parent handler pointer ? Code: (Select All) Byval hWndParent As Offset RE: GUI app and winAPI calls - aurel - 03-22-2023 things go more weird when compiler exit with syntax error about parens ( and code is this : Code: (Select All) FUNCTION CreateWindowEx%& (ByVal dwExStyle As Long, Byref lpClassName As String, Byref lpWindowName As String, Byval dwStyle As Long, Byval x As Long, Byval y As Long, Byval nWidth As Long, Byval nHeight As Long, Byval hWndParent As Long, Byval hMenu As Long, Byval hInstance As Long, Byval lpParam As Long ) RE: GUI app and winAPI calls - aurel - 03-22-2023 and more Zak you use Offset without _OFFSET ...so what i s proper ? RE: GUI app and winAPI calls - aurel - 03-22-2023 I really don't get it what is problem with _OFFSET or probably i am doing something wrong here is code: Code: (Select All) 'test 1 GUI win32 api in QB64pe v3.2.1 by Aurel RE: GUI app and winAPI calls - SpriggsySpriggs - 03-22-2023 It looks like this is because you defined "hw" as LONG but CreateWindowEx returns an OFFSET. Make sure all your handles are OFFSETs. As for the underscore vs not.... I usually code with $NOPREFIX turned on and I just copied and pasted from code I had opened. Oops. Also, your declaration for CreateWindowEx has some variable type mismatches. Copy the declaration I gave you (but fix the underscores) and also replace DECLARE DYNAMIC LIBRARY "user32" in your code with DECLARE CUSTOMTYPE LIBRARY. Otherwise, you're going to need the "A" at the end of CreateWindowEx. If you don't change either the library declaration or the name of the function, then you will hit a runtime error saying that function doesn't exist in the library. RE: GUI app and winAPI calls - aurel - 03-22-2023 Quote:Make sure all your handles are OFFSETs. all handles must be _OFFSET ..why ..in other windows compilers there are INTEGER or LONG why is in QB64 pointer? and also when i try to copy code original author made this as className ..what is that hw = CreateWindowEx(0, at AND &HFFFF~&, _OFFSET(t1), WS_OVERLAPPEDWINDOW , 200, 200, 800, 600, 0, 0, hi, 0) RE: GUI app and winAPI calls - mnrvovrfc - 03-22-2023 (03-22-2023, 08:13 PM)aurel Wrote: all handles must be _OFFSET ..why ..in other windows compilers there are INTEGER or LONG It was a half-successful attempt to ease the life of the programmer moving from 32-bit to 64-bit. A pointer isn't supposed to be dictated by what's its size. Remember that _OFFSET and _MEM are necessary in QB64(PE) because otherwise it would have to look like Freebasic or Purebasic which, in turn, look the most like C and C++. I guess in this case use ConvertOffset&&() function that Steve wrote and is in QB64 Wiki. But that returns _INTEGER64 and not INTEGER or LONG. INTEGER is always 16-bit integer in QuickBASIC and descendants, shouldn't be discussed any longer in systems programming. RE: GUI app and winAPI calls - SpriggsySpriggs - 03-22-2023 A HANDLE is a long pointer. In QB64, our equivalent is an OFFSET. A long pointer is 4 bytes in 32 bit and 8 in 64. In QB64, an OFFSET is 4 bytes in 32 bit and 8 in 64. It's our closest approximation. As for the class name with the "at AND &HFFFF~&", I'm not sure where they would have gotten that value for their class. Very odd. I've not seen something like that before. If I were you, I'd instead use the actual name of the class and keep the declaration with OFFSET. It looks like you defined it as "QB64pe". So just pass it as _OFFSET(ClassName) in your call there rather than that weird "at AND &HFFFF~&". |