Oxygen Basic
Programming => Problems & Solutions => Topic started by: Aurel on February 04, 2014, 02:55:01 AM
-
Hi
Do you know that RegisterClass not work outside of Bind structure?
RegisterClass-Funktion
Diese Funktion registriert eine Klasse, die dann dazu benutzt werden kann, ein Fenster zu erstellen.
Betriebssystem: Win95, Win98, WinNT 3.1, Win2000, WinME
so something like this not work on XP,Vista,7
Declare Function RegisterClass Lib "user32.dll" Alias "RegisterClassA" ( lpWndClass As WNDCLASS) As Long
I will try replace this with RegisterClassEx...
-
Are you using a matching WNDCLASS structure?
Declare Function RegisterClass lib "user32" Alias "RegisterClassA" (Class As WNDCLASS) As Long
Declare Function RegisterClassEx lib "user32" Alias "RegisterClassExA" (pcWndClassEx As WNDCLASSEX) As Integer
-
Hi Charles..
As i say this:
Declare Function RegisterClass Lib "user32.dll" Alias "RegisterClassA" ( lpWndClass As WNDCLASS) As Long
not work outside of Bind structrure:
Bind user32
(
'LoadIcon LoadIconA
'LoadCursor LoadCursorA
RegisterClass RegisterClassA
...
...
)
or in another words if u use RegisterClass from Bind user32 then program work properly.
So my question is why some api functions not work outside of bind scope?
-
Unfortunatelly
sorry but NOT work...
If is inside Bind() like:
Bind user32
(
LoadIcon LoadIconA
LoadCursor LoadCursorA
RegisterClass RegisterClassA
RegisterClassEx RegisterClassExA
....
....
)
Then Work. ::)
But if is declared outside like this :
Declare Function RegisterClassEx Lib "user32.dll" Alias "RegisterClassExA" ( lpwcx As WNDCLASSEX) As Integer
then NOT work...
Charles...
Please , do you can remove this dependecies ?
-
How are you calling it, Aurel?
with the fully specified prototype:
RegisterClassEx wcx
-
Yes Charles
Like you show
RegisterClassEx &wcx
-
With your prototype there should no '&' or '@', because it passes ByRef (implicitly when using basic-style prototypes).
-
With your prototype there should no '&' or '@', because it passes ByRef (implicitly when using basic-style prototypes).
wait,,,Charles ..so you say that I use all the time wrong method :o
so proper way would be
RegisterClassEx wcx ....... right?
-
Hi Aurel, it depends on the prototype you use. If the prototype implies parameters 'BYREF' then '&' is not used.
-
Ok
I will try all possible options
and i will present here skeleton app with minimum of api functions.
-
Hi Charles...
After i test all possible options it looks that RegisterClassEx and also RegisterClass
NOT work without Bind().
What might be problem i really cannot understand ???
'skeleton VB way...
$ filename "skeleton.exe"
include "rtl32.inc"
'#lookahead
'structures
Type WNDCLASSEX
cbSize as long
Style as long
lpfnwndproc as sys
cbClsextra as long
cbWndExtra as long
hInstance as sys
hIcon as long
hCursor as long
hbrBackground as long
lpszMenuName as string
lpszClassName as string
hIconSm AS long
End Type
Type WNDCLASS
style As Long
lpfnwndproc As Long
cbClsextra As Long
cbWndExtra As Long
hInstance As Long
hIcon As Long
hCursor As Long
hbrBackground As Long
lpszMenuName As String
lpszClassName As String
End Type
Type POINTAPI
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 PointApi
End Type
'constants
% IDI_WINLOGO = 32517
% IDI_APPLICATION = 32512
% IDC_ARROW = 32512
% CS_OWNDC = 32
% CS_DBLCLKS = &H8
% SW_NORMAL = 1
% 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 = 0x80000
% WS_OVERLAPPED = WS_SYSMENU
% WS_POPUP = 0x80000000
% WS_DLGFRAME = 0x400000
% WS_VISIBLE = 0x10000000
'defines...
Def WHITE_BRUSH 0
Def BLACK_BRUSH 4
'declarations...
Declare Function MessageBox Lib "kernel32.dll" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
Declare Function LoadIcon Lib "user32.dll" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As Any) As Long
Declare Function LoadCursor Lib "user32.dll" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As Long
Declare Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (sys lpModuleName) as Long
Declare Function RegisterClassEx Lib "user32.dll" Alias "RegisterClassExA" (wcx as WNDCLASSEX) as Long
Declare Function RegisterClass Lib "user32.dll" Alias "RegisterClassA" (byref lpwcx as WNDCLASS) as Long
Declare Function CreateWindowEx Lib "user32.dll" Alias "CreateWindowExA" (byval dwExStyle AS INT,byval lpClassName AS STRING,byval lpWindowName AS STRING,byval dwStyle AS INT,byval x AS INT,byval y AS INT,byval nWidth AS INT,byval nHeight AS INT,byval hWndParent AS INT,byval hMenu AS INT,byval hInstance AS INT,byval lpParam AS INT) as Long
Declare Function TranslateMessage Lib "user32.dll" Alias "TranslateMessageA" (byval lpMsg as Long) as Long
Declare Function DispatchMessage Lib "user2.dll" Alias "DispatchMessageA" (byval lpMsg as Long) as Long
Declare Function GetMessage Lib "user32.dll" Alias "GetMessageA" (byval lpMsg As MSG, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal nCmdShow 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 PostQuitMessage Lib "user32.dll" (ByVal nExitCode As Long)
Dim wcx as WNDCLASSEX
Dim wm as MSG
'FILL WNDCLASSEX structure
inst = GetModuleHandle 0
wcx.cbSize = sizeOf(WNDCLASSEX)
wcx.style = CS_DBLCLKS Or CS_OWNDC
wcx.lpfnWndProc = &WndProc
wcx.cbClsExtra = 0
wcx.cbWndExtra = 0
wcx.hInstance = inst
wcx.hIcon = LoadIcon 0,IDI_WINLOGO
wcx.hCursor = LoadCursor 0,IDC_ARROW
wcx.hbrBackground = WHITE_BRUSH
wcx.lpszMenuName = ?0
wcx.lpszClassName = strptr"Oxygen"
wcx.hIconSm = LoadIcon 0,IDI_APPLICATION
'register window class Ex
RegisterClassEx wcx
'create window -------------------------------
Dim hwnd,style, Wx, Wy, Ww, Wh, wparent as Long
Dim caption as String
'-------------------------------
caption = "MyWindow"
style = WS_VISIBLE or WS_SYSMENU 'WS_OVERLAPPEDWINDOW
Wx=0 : Wy=0 : Ww=640 : Wh=480
wparent = 0 'HWND_DESKTOP
'-------------------------------
Hwnd = CreateWindowEx 0, wcx.lpszClassName, caption, style, Wx, Wy, Ww, Wh, wparent, 0, inst, byval 0
ShowWindow Hwnd,SW_NORMAL
'-------------------------------
'message loop
WHILE Getmessage(wm,0,0,0) <> 0
TranslateMessage wm
DispatchMessage wm
WEND
'main callback procedure ---------------------------------------
Function WndProc (sys wMsg,Hwnd,wParam,lParam) as sys callback
Select wMsg
CASE WM_DESTROY
PostQuitMessage 0
End Select
Return DefWindowProc(wMsg,Hwnd,wParam,lParam)
End Function
'----------------------------------------------------------------
.
-
Here is another corection but still not work ???
'skeleton VB way...
$ filename "skeleton.exe"
include "rtl32.inc"
#lookahead
'structures
Type WNDCLASSEX
cbSize as long
Style as long
lpfnwndproc as sys
cbClsextra as long
cbWndExtra as long
hInstance as sys
hIcon as long
hCursor as long
hbrBackground as long
lpszMenuName as string
lpszClassName as string
hIconSm AS long
End Type
Type POINTAPI
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 PointApi
End Type
'constants
% IDI_WINLOGO = 32517
% IDI_APPLICATION = 32512
% IDC_ARROW = 32512
% CS_OWNDC = 32
% CS_DBLCLKS = &H8
% SW_NORMAL = 1
% 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 = 0x80000
% WS_OVERLAPPED = WS_SYSMENU
% WS_POPUP = 0x80000000
% WS_DLGFRAME = 0x400000
% WS_VISIBLE = 0x10000000
'defines...
Def WHITE_BRUSH 0
Def BLACK_BRUSH 4
'declarations...
Declare Function MessageBox Lib "kernel32.dll" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
Declare Function LoadIcon Lib "user32.dll" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As Any) As Long
Declare Function LoadCursor Lib "user32.dll" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As Long
Declare Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (sys lpModuleName) as Long
Declare Function RegisterClassEx Lib "user32.dll" Alias "RegisterClassExA" (WNDCLASSEX *lpwcx) as Long
'Declare Function RegisterClass Lib "user32.dll" Alias "RegisterClassA" (byref lpwcx as WNDCLASS) as Long
Declare Function CreateWindowEx Lib "user32.dll" Alias "CreateWindowExA" (byval dwExStyle AS INT,byval lpClassName AS STRING,byval lpWindowName AS STRING,byval dwStyle AS INT,byval x AS INT,byval y AS INT,byval nWidth AS INT,byval nHeight AS INT,byval hWndParent AS INT,byval hMenu AS INT,byval hInstance AS INT,byval lpParam AS INT) as Long
Declare Function TranslateMessage Lib "user32.dll" (byref lpMsg as Long) as Long
Declare Function DispatchMessage Lib "user32.dll" Alias "DispatchMessageA" (byref lpMsg as Long) as Long
Declare Function GetMessage Lib "user32.dll" Alias "GetMessageA" (byval lpMsg As MSG, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal nCmdShow 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 Sub PostQuitMessage Lib "user32.dll" (ByVal nExitCode As Long)
Dim wcx as WNDCLASSEX
Dim wm as MSG
'FILL WNDCLASSEX structure
inst = GetModuleHandle 0
wcx.cbSize = sizeOf(WNDCLASSEX)
wcx.style = CS_DBLCLKS Or CS_OWNDC
wcx.lpfnWndProc = &WndProc
wcx.cbClsExtra = 0
wcx.cbWndExtra = 0
wcx.hInstance = inst
wcx.hIcon = LoadIcon 0,IDI_WINLOGO
wcx.hCursor = LoadCursor 0,IDC_ARROW
wcx.hbrBackground = WHITE_BRUSH
wcx.lpszMenuName = ?0
wcx.lpszClassName = strptr"Oxygen"
wcx.hIconSm = LoadIcon 0,IDI_APPLICATION
'register window class Ex
RegisterClassEx wcx
'create window -------------------------------
Dim hwnd,style, Wx, Wy, Ww, Wh, wparent as Long
Dim caption as String
'-------------------------------
caption = "MyWindow"
style = WS_OVERLAPPEDWINDOW
Wx=0 : Wy=0 : Ww=640 : Wh=480
wparent = 0 'HWND_DESKTOP
'-------------------------------
Hwnd = CreateWindowEx 0, wcx.lpszClassName, caption, style, Wx, Wy, Ww, Wh, wparent, 0, inst, byval 0
ShowWindow Hwnd,SW_NORMAL
'-------------------------------
'message loop
WHILE GetMessage(wm,0,0,0) <> 0
TranslateMessage wm
DispatchMessage wm
WEND
'main callback procedure ---------------------------------------
Function WndProc (sys hwnd,wMsg,wParam,lParam) as sys callback
Select wMsg
CASE WM_DESTROY
PostQuitMessage 0
End Select
Return DefWindowProc(Hwnd,wMsg,wParam,lParam)
End Function
'------------------------------------------
-
I found one of the O2 examples specifically demos RegisterClassEx. It works with MinWin.inc
/examples/RegisterClassEx.o2bas
$ filename "t.exe"
'#include "..\..\inc\RTL32.inc"
#include "../../inc/MinWin.inc"
s=error()
'
if s then
print s
end
end if
% ID_Timer 3000
% Interval 100
'==================
'GLOBAL DEFINITIONS
'==================
sys inst,hdc
sys xmax,ymax,r,idx,idy,xball,yball
r =15 : idx =5 : idy=5 : xball=200 : yball=100
dim as rect crect 'for WndProc
'--------------------------------------------------------------------------------------------------------------------------
function WndProc ( byval hWnd as long, byval wMsg as long, byval wParam as long, byval lparam as long ) as long callback
'==========================================================================================================================
static as sys count=0, refreshes=0, hdc, keycode, charcode
static as String txt
static as PaintStruct Paintst
'==========
select wMsg
'==========
'--------------
case WM_CREATE
'=============
hTimer = SetTimer hWnd, ID_Timer, 50, 0
GetClientRect hWnd,@cRect
'--------------
case WM_TIMER
'=============
InvalidateRect hwnd,@crect,1
'--------------
case WM_DESTROY
'===============
KillTimer(hWnd,ID_TIMER)
PostQuitMessage 0
'------------
case WM_PAINT
'============
'TEXT
'http://msdn.microsoft.com/en-us/library/dd144821(v=VS.85).aspx
'DRAWING AND PAINTING
'http://msdn.microsoft.com/en-us/library/dd162760(v=VS.85).aspx
hDC=BeginPaint hWnd,@Paintst
GetClientRect hWnd,@cRect
'style
'0x20 DT_SINGLELINE
'0x04 DT_VCENTER
'0x01 DT_CENTER
'0x25
SetBkColor hdc,white
SetTextColor hdc,blue
'
txt="Key Code 0x" hex(keycode) " Char Code 0x" hex(charcode)
'
DrawText hDC,*txt,-1,@cRect,0x25
EndPaint hWnd,@Paintst
ValidateRect hwnd,@crect
'-----------
case WM_CHAR
'===========
charcode=wparam
'--------------
case WM_KEYDOWN
'==============
keycode=wParam : charcode=0
if wParam=27 then SendMessage hwnd, WM_CLOSE, 0, 0 'ESCAPE
'--------
case else
'========
function=DefWindowProc hWnd,wMsg,wParam,lParam
end select
end function ' WndProc
'----------------------------------------------------------------------
Function WinMain(sys inst, prevInst,zstring* cmdline, sys show) as long
'======================================================================
WNDCLASSEX wc
MSG wm
string ClassName="Demo", MenuName="Menu"
sys hwnd, wwd, wht, wtx, wty, tax
'
wc.cbSize=sizeof WNDCLASSEX
wc.style = CS_HREDRAW or CS_VREDRAW
wc.lpfnWndProc = @WndProc
wc.cbClsExtra =0
wc.cbWndExtra =0
wc.hInstance =inst
wc.hIcon=LoadIcon 0, IDI_APPLICATION
wc.hCursor=LoadCursor 0,IDC_ARROW
wc.hbrBackground = GetStockObject WHITE_BRUSH
wc.lpszMenuName = strptr MenuName
wc.lpszClassName = strptr ClassName
wc.hIconSm=0
'
a=RegisterClassEx (@wc)
'
Wwd = 340 : Wht = 160
Tax = GetSystemMetrics SM_CXSCREEN
Wtx = (Tax - Wwd) /2
Tax = GetSystemMetrics SM_CYSCREEN
Wty = (Tax - Wht) /2
hwnd = CreateWindowEx 0,wc.lpszClassName,"OXYGEN BASIC",WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0
ShowWindow hwnd,SW_SHOW
UpdateWindow hwnd
'
sys bRet
'
do while bRet := GetMessage (@wm, 0, 0, 0)
if bRet = -1 then
'show an error message
exit while
else
TranslateMessage @wm
DispatchMessage @wm
end if
wend
End Function
'=========
'MAIN CODE
'=========
dim cmdline as asciiz ptr,inst as long
@cmdline=GetCommandLine
inst=GetModuleHandle 0
'
'WINDOWS
'-------
'
WinMain inst,0,cmdline,SW_NORMAL
end
type WNDCLASSEX
int cbSize
int Style
sys lpfnwndproc
int cbClsextra
int cbWndExtra
sys hInstance
sys hIcon
sys hCursor
sys hbrBackground
sys lpszMenuName
sys lpszClassName
sys hIconSm
end type
PS:
TranslateMessage does not have an A or W specifier, unlike DispatchMessage
-
Yes Charles
i see and i remove this A but program still just stuck in memory.
Ok i will study this code ;)
Yes i do all changes but still just stuck.
and this example don't use Bind() method but use
extern Lib "user32.dll"
-
Assign strings using strptr with these two:
sys lpszMenuName
sys lpszClassName
lpszClassName = strptr "Demo"
-
ok i do this and again nothing ???
here is my code so you can try:..
'skeleton VB way...
$ filename "skeleton.exe"
'include "rtl32.inc"
'#lookahead
'structures
Type WNDCLASSEX
cbSize as int
Style as int
lpfnwndproc as sys
cbClsextra as int
cbWndExtra as int
hInstance as sys
hIcon as sys
hCursor as sys
hbrBackground as sys
lpszMenuName as sys
lpszClassName as sys
hIconSm AS sys
End Type
Type POINTAPI
x as long
y as long
End Type
Type MSG
hwnd as sys
message as int
wParam as sys
lParam as sys
time as dword
pt as POINTAPI
End Type
'constants
% IDI_WINLOGO = 32517
% IDI_APPLICATION = 32512
% IDC_ARROW = 32512
% CS_OWNDC = 32
% CS_DBLCLKS = &H8
% SW_NORMAL = 1
% SW_SHOW = 5
% 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 = 0x80000
% WS_OVERLAPPED = WS_SYSMENU
% WS_POPUP = 0x80000000
% WS_DLGFRAME = 0x400000
% WS_VISIBLE = 0x10000000
'defines...
Def WHITE_BRUSH 0
Def BLACK_BRUSH 4
'declarations...
'Declare Function MessageBox Lib "kernel32.dll" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
Declare Function LoadIcon Lib "user32.dll" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As Any) As Long
Declare Function LoadCursor Lib "user32.dll" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As Long
Declare Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (sys lpModuleName) as Long
Declare Function RegisterClassEx Lib "user32.dll" Alias "RegisterClassExA" (WNDCLASSEX *lpwcx) as Long
'Declare Function RegisterClass Lib "user32.dll" Alias "RegisterClassA" (byref lpwcx as WNDCLASS) as Long
Declare Function CreateWindowEx Lib "user32.dll" Alias "CreateWindowExA" (byval dwExStyle AS INT,byval lpClassName AS STRING,byval lpWindowName AS STRING,byval dwStyle AS INT,byval x AS INT,byval y AS INT,byval nWidth AS INT,byval nHeight AS INT,byval hWndParent AS INT,byval hMenu AS INT,byval hInstance AS INT,byval lpParam AS INT) as Long
Declare Function TranslateMessage Lib "user32.dll" (lpMsg as Long) as Long
Declare Function DispatchMessage Lib "user32.dll" Alias "DispatchMessageA" (lpMsg as Long) as Long
Declare Function GetMessage Lib "user32.dll" Alias "GetMessageA" (byval lpMsg As MSG, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal nCmdShow 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 Sub PostQuitMessage Lib "user32.dll" (ByVal nExitCode As Long)
Dim wcx as WNDCLASSEX
Dim wm as MSG
'FILL WNDCLASSEX structure
inst = GetModuleHandle 0
wcx.cbSize = sizeOf(WNDCLASSEX)
wcx.style = CS_DBLCLKS Or CS_OWNDC
wcx.lpfnWndProc = &WndProc
wcx.cbClsExtra = 0
wcx.cbWndExtra = 0
wcx.hInstance = inst
wcx.hIcon = LoadIcon 0,IDI_APPLICATION
wcx.hCursor = LoadCursor 0,IDC_ARROW
wcx.hbrBackground = WHITE_BRUSH
wcx.lpszMenuName = strptr "menu"
wcx.lpszClassName = strptr "Oxygen"
wcx.hIconSm = 0
'register window class Ex
RegisterClassEx wcx
'create window -------------------------------
Dim hwnd,style, Wx, Wy, Ww, Wh, wparent as Long
Dim caption as String
'-------------------------------
caption = "MyWindow"
style = WS_OVERLAPPEDWINDOW
Wx=0 : Wy=0 : Ww=640 : Wh=480
wparent = 0 'HWND_DESKTOP
'-------------------------------
Hwnd = CreateWindowEx 0, wcx.lpszClassName, caption, style, Wx, Wy, Ww, Wh, wparent, 0, inst,0
ShowWindow Hwnd,SW_SHOW
'-------------------------------
'message loop
WHILE GetMessage(wm,0,0,0) <> 0
TranslateMessage wm
DispatchMessage wm
WEND
'main callback procedure ---------------------------------------
Function WndProc (sys hwnd,wMsg,wParam,lParam) as sys callback
Select wMsg
CASE WM_DESTROY
PostQuitMessage 0
End Select
Return DefWindowProc(Hwnd,wMsg,wParam,lParam)
End Function
'------------------------------------------
-
Lots of errors, too hard to read, but I got it working after a fashion..
.
-
First of all thank you Charles..
and there is no lots of errors at all
the main problem I was made in
udt :
wcx.lpszClassName inside
CreateWindowEx which need string pointer
and just one thing i have never made default return inside SELECT
in WndProc
Another point i have made mistake with WHITE_BRUSH which must be 4 not 0.
Hard to read ???
It is very easy to read and i don't see why is hard because represent classic VB way of
window creation.
All in all it is easier to use Bind which i use in my other programs.
Thanks again ;)
-
So
Here we are ... after creating exe file on this (almost VB way) i get only
3 alert from Virus Total site and this is the proof that using VB or if you
whish most standard way of declared Api functions cose less virus alerts.
and that is good!
AntiVir TR/Crypt.XPACK.Gen2 20140208
Emsisoft Backdoor.Generic.840440 (B) 20140209
Rising PE:Malware.XPACK-LNR/Heur!1.5594 20140208
AVG 20140209
Ad-Aware 20140209
Agnitum 20140208
AhnLab-V3 20140208
Antiy-AVL 20140208
Avast 20140209
Baidu-International 20140209
BitDefender 20140209
Bkav 20140208
ByteHero 20140209
CAT-QuickHeal 20140208
CMC 20140122
ClamAV 20140209
Commtouch 20140209
Comodo 20140209
DrWeb 20140209
ESET-NOD32 20140208
F-Prot 20140209
F-Secure 20140209
Fortinet 20140209
GData 20140209
Ikarus 20140209
Jiangmin 20140209
K7AntiVirus 20140207
K7GW 20140207
Kaspersky 20140209
Kingsoft 20140209
Malwarebytes 20140209
McAfee 20140209
McAfee-GW-Edition 20140209
MicroWorld-eScan 20140209
Microsoft 20140209
NANO-Antivirus 20140209
Norman 20140209
Panda 20140208
Qihoo-360 20140209
SUPERAntiSpyware 20140208
Sophos 20140209
Symantec 20140209
TheHacker 20140208
TotalDefense 20140208
TrendMicro 20140209
TrendMicro-HouseCall 20140209
VBA32 20140207
VIPRE 20140209
ViRobot 20140209
nProtect 20140209
-
Hi Aurel,
If you want to use VB-style headers then I recommend looking at /projectsB/WinApiVB6/
There is a substantial hunk of the VB headers in there, which Kent put together.
All the type definitions containing string have been replaced by char*.
This will allow you to assign strings to these members in the normal way without strptr
But this API will not support 64 bit binaries due to using 'long' and 'dword' for pointers/handles.
-
Hi Aurel,
If you want to use VB-style headers then I recommend looking at /projectsB/WinApiVB6/
There is a substantial hunk of the VB headers in there, which Kent put together.
All the type definitions containing string have been replaced by char*.
This will allow you to assign strings to these members in the normal way without strptr
But this API will not support 64 bit binaries due to using 'long' and 'dword' for pointers/handles.
Hi Charles,
Main point ,as you can see , is security and avoid so many virus alerts .
And it looks that i have a right about that.
If you ask me i like to use Bind(),but as you see it looks that using Bind() we produce virus alerts
and i want that my exe-s are clean as possible.
If you ask me about strptr ...i like to use strptr ;)
Thanks for help ;)
-
The more recent MinWins no longer use bind. The conversion is very simple:
Example: User32.dll
extern lib "User32.dll"
! LoadIcon "LoadIconA" '2
! LoadCursor "LoadCursorA" '2
! LoadImage "LoadImageA" '6
! RegisterClass "RegisterClassA" '1
! RegisterClassEx "RegisterClassExA" '1
! UnregisterClass "UnregisterClassA" '1
! ShowCursor '1
! MessageBox "MessageBoxA" '1
! CreateWindowEx "CreateWindowExA" '12
! ShowWindow '2
! UpdateWindow '1
! AdjustWindowRectEx '4
! GetMessage "GetMessageA" '4
! PeekMessage "PeekMessageA" '5
! TranslateAccelerator '3
! TranslateMessage '1
! DispatchMessage "DispatchMessageA" '1
! PostQuitMessage '1
! BeginPaint '2
! EndPaint '2
! GetClientRect '2
! GetWindowRect '2
! DrawText "DrawTextA" '5
! PostMessage "PostMessageA" '4
! DefWindowProc "DefWindowProcA" '4
! EnumChildWindows '3
! MoveWindow '6
! DestroyWindow '1
! GetWindowLong "GetWindowLongA" '2
! FillRect '3
! GetDC '1
! GetWindowDC '1
! ReleaseDC '2
! SetTimer '4
! KillTimer '2
! GetCapture '0
! ReleaseCapture '0
! SetCapture '1
! GetAsyncKeyState '1
! InvalidateRect '3
! ValidateRect '2
! SendMessage "SendMessageA" '4
! GetSystemMetrics '1
! EmptyClipboard '0
! OpenClipboard '1
! CloseClipboard '1
! GetClipboardData '1
! SetClipboardData '2
! GetFocus '0
! SetFocus '1
! SetWindowText "SetWindowTextA" '2
! SetWindowPos '7
! SetForegroundWindow '1
! EnumDisplaySettings "EnumDisplaySettingsA" '3
! ChangeDisplaySettings "ChangeDisplaySettingsA"'2
! LoadAccelerators "LoadAcceleratorsA" '2
! DialogBoxParam "DialogBoxParamA" '5
! EndDialog '2
! CreateMenu '0
! InsertMenu "InsertMenuA" '5
! CreatePopupMenu '0
! TrackPopupMenu '7
! DestroyMenu '1
! GetMenu '1
! GetSystemMenu '0
! SetMenu '2
! AppendMenu "AppendMenuA" '4
! CheckMenuItem '3
! EnableMenuItem '3
end extern
These are the same as declare function statements, but prototypes are optional :)