WNDCLASSEX seems for some reason not to work.
I had this problem earlier and gave up
Try this,
Type WNDCLASSEX
cbSize as long
Style as long
lpfnwndproc as long
cbClsextra as long
cbWndExtra as long
hInstance as long
hIcon as long
hIconSm as long
hCursor as long
hbrBackground as long
lpszMenuName as long
lpszClassName as long
End Type
Type WNDCLASS
Style as sys
lpfnwndproc as sys
cbClsextra as sys
cbWndExtra as sys
hInstance as sys
hIcon as sys
hCursor as sys
hbrBackground as sys
lpszMenuName as sys
lpszClassName as sys
End Type
Type Point
x as sys
y as sys
End Type
Type MSG
hwnd as sys
message as sys
wParam as sys
lParam as sys
time as sys
pt as sys
End Type
Type RECT
Left as sys
Top as sys
Right as sys
Bottom as sys
End Type
% IDI_APPLICATION= 32512
% CS_DBLCLKS = 8
% SW_NORMAL = 1
% SW_SHOWDEFAULT = 10
% SW_SHOW = 5
% CS_VREDRAW = 1
% CS_HREDRAW = 2
% CS_OWNDC = 32
% SM_CXSCREEN = 0
% SM_CYSCREEN = 1
% IDI_WINLOGO = 32517
% IDC_ARROW = 32512
% WM_CREATE = 1
% WM_DESTROY = 2
% WM_PAINT = 15
% WM_QUIT = 18
% WM_SIZE = 5
% WM_MOVE = 3
% WM_CHAR = 258
% WM_KEYDOWN = 256
% WM_KEYUP = 257
% WM_MOUSEMOVE = 512
% WM_MBUTTONDOWN = 519
% WM_LBUTTONDOWN = 513
% WM_RBUTTONDOWN = 516
% WM_LBUTTONUP = 514
% WM_RBUTTONUP = 517
% WM_MBUTTONUP = 520
% WS_OVERLAPPEDWINDOW = 0x00cf0000
% WS_SYSMENU = 524288
% WS_OVERLAPPED = WS_SYSMENU
% WS_POPUP = 0x80000000
% WS_DLGFRAME = 0x400000
% WHITE_BRUSH = 0
% BLACK_BRUSH = 4
Declare Function SetTextColor Lib "gdi32.dll" (ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function TextOut Lib "gdi32.dll" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Declare Function DestroyWindow Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function GetDC Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function SetBkColor Lib "gdi32.dll" (ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function SetBkMode Lib "gdi32.dll" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long
Declare Function GetStockObject Lib "gdi32.dll" (ByVal nIndex As Long) As Long
Declare Function ReleaseDC Lib "user32.dll" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
Declare Function ValidateRect Lib "user32.dll" (ByVal hwnd As Long, ByRef lpRect As RECT) As Long
Declare Function InvalidateRect Lib "user32.dll" (ByVal hwnd As Long, ByRef lpRect As RECT, ByVal bErase As Long) As Long
Declare Function DefWindowProc Lib "user32.dll" Alias "DefWindowProcA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
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 Any) As Long
Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function DispatchMessage Lib "user32.dll" Alias "DispatchMessageA" (ByRef lpMsg As MSG) As Long
Declare Function TranslateMessage Lib "user32.dll" (ByRef lpMsg As MSG) As Long
Declare Function GetMessage Lib "user32.dll" Alias "GetMessageA" (ByRef lpMsg As MSG, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Declare Function MessageBox Lib "user32.dll" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
Declare Function RegisterClass Lib "user32.dll" Alias "RegisterClassA" (ByRef Class As WNDCLASS) As Long
Declare Function RegisterClassEx Lib "user32.dll" Alias "RegisterClassExA" (ByRef pcWndClassEx As WNDCLASSEX) As Long
Declare Function LoadCursor Lib "user32.dll" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As String) As Long
Declare Function LoadIcon Lib "user32.dll" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As String) As Long
Declare Function GetCommandLine Lib "kernel32.dll" Alias "GetCommandLineA" () As String
Declare Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Declare Function Beep Lib "kernel32.dll" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
Declare Function GetPixel Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function SetPixel Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Declare Function Rectangle Lib "gdi32.dll" Alias "Rectangle" (ByVal hdc As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As Long
Declare Sub ExitProcess Lib "kernel32.dll" (ByVal uExitCode As Long)
Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Declare Sub PostQuitMessage Lib "user32.dll" (ByVal nExitCode As Long)
sys wx, wy, ww, wh, scr, inst, sys_hwnd, sys_hdc, caption, style
Dim wdx as WNDCLASSEX
Dim wm as MSG
String s = "SIMPLE WINDOW"
Function HiWord(sys high) as sys
shr high,16
Return high
End Function
Function LoWord(sys low) as sys
and low,&hFFFF
Return low
End Function
Function WndProc(sys hWnd, wMsg, wParam, lparam) as long callback
iF wMsg = WM_CREATE
'
ElseiF wMsg = WM_PAINT
SetBkMode sys_hdc,1
SetTextColor sys_hdc,255
TextOut sys_hdc,240,200,s,Len(s)
SetTextColor sys_hdc,0x008000
TextOut sys_hdc,240,212,s,Len(s)
ValidateRect hwnd, 0
'
ElseiF wMsg = WM_DESTROY
PostQuitMessage 0
Else
Function = DefWindowProc hWnd,wMsg,wParam,lParam
End iF
End Function
inst = GetModuleHandle 0
wdx.cbSize = sizeof(WNDCLASSEX)
wdx.style = CS_DBLCLKS
wdx.lpfnWndProc = &WndProc
wdx.cbClsExtra =0
wdx.cbWndExtra =0
wdx.hInstance = inst
wdx.hIcon=LoadIcon 0,IDI_APPLICATION
wdcx.hIconSm=LoadIcon 0,IDI_APPLICATION
wdx.hCursor=LoadCursor 0,IDC_ARROW
wdx.hbrBackground = 1
wdx.lpszMenuName = caption
wdx.lpszClassName ="Winx"
RegisterClassEx (@wdx)
scr = GetSystemMetrics SM_CXSCREEN
wx = (scr - 640) /2
Scr = GetSystemMetrics SM_CYSCREEN
wy = (scr - 480) /2
sys_hwnd = CreateWindowEx 0, wdx.lpszClassName, caption, style, wx, wy, ww, wh, 0, 0, inst, 0
ShowWindow sys_hwnd, SW_SHOW
sys_hdc = GetDC(sys_hwnd)
While GetMessage &wm,0,0,0
iF wm.message = Wm_Quit
ReleaseDC sys_hwnd,sys_hdc
DestroyWindow sys_hwnd
ExitProcess 0
End iF
TranslateMessage &wm
DispatchMessage &wm
Wend