Author Topic: Window Technic  (Read 2019 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
Window Technic
« on: January 22, 2014, 12:29:15 PM »
Deleted
« Last Edit: April 25, 2015, 03:09:17 AM by Peter »

Frankolinox

  • Guest
Re: Window Technic
« Reply #1 on: January 27, 2014, 08:29:14 AM »
hello peter, after testing your example code I've noticed that the win gui doesn't close properly (gpf), there's missing something.

regards, frank

Aurel

  • Guest
Re: Window Technic
« Reply #2 on: January 27, 2014, 10:19:51 AM »
Sorry Peter...but Frank have a right,program crush because
of this :

'InvalidateRect hWnd,0,0

@frank
remove this line and program will work properly

Aurel

  • Guest
Re: Window Technic
« Reply #3 on: January 27, 2014, 12:22:25 PM »
Peter
do you can try this way..

Code: [Select]
/*   BY PETER   */   
Type WNDCLASS
    long style       
    long lpfnwndproc   
    long cbClsextra   
    long cbWndExtra   
    long hInstance     
    long hIcon         
    long hCursor       
    long hbrBackground
    long lpszMenuName 
    long lpszClassName
End Type

Type POINT
    long x
    long y
End Type

Type MSG
    long hwnd   
    long message
    long wParam 
    long lParam 
    long time   
    POINT pt   
End Type

% NULL_BRUSH   = 5
% SW_SHOW      = 5
% CS_VREDRAW   = 1
% CS_HREDRAW   = 2
% WM_CREATE    = 1
% WM_DESTROY   = 2
% WM_PAINT     = 15
% WM_QUIT      = 18

% IDI_WINLOGO  = 32517
% IDC_ARROW    = 32512
% COLOR_WINDOW = 5
% WS_OVERLAPPED= 0x80000     

sys user32
user32 = LoadLibrary "user32.dll"

Bind user32
(
  CreateWindowEx  CreateWindowExA
  ValidateRect    ValidateRect
  InValidateRect  InValidateRect
  ReleaseDC       ReleaseDC
)   

! GetModuleHandle   Lib "kernel32.dll" Alias "GetModuleHandleA" (string lpModuleName) As sys

! ShowWindow        Lib "user32.dll"   (sys hwnd, nCmdShow) As sys
! UpdateWindow      Lib "user32.dll"   (sys hwnd) As sys
! RegisterClass     Lib "user32.dll"   Alias "RegisterClassA" (WNDCLASS *Class) As sys
! GetMessage        Lib "user32.dll"   Alias "GetMessageA" (MSG *lpMsg, sys hwnd, wMsgFilterMin, wMsgFilterMax) As sys
! DispatchMessage   Lib "user32.dll"   Alias "DispatchMessageA" (MSG *lpMsg)  As sys
! TranslateMessage  Lib "user32.dll"   (MSG *lpMsg) As sys
! LoadIcon          Lib "user32.dll"   Alias "LoadIconA" (sys hInstance, string lpIconName) As sys
! LoadCursor        Lib "user32.dll"   Alias "LoadCursorA" (sys hInstance, string lpCursorName) As sys
! PostQuitMessage   Lib "user32.dll"   (sys nExitCode)
! DefWindowProc     Lib "user32.dll"   Alias "DefWindowProcA" (sys hwnd, wMsg, wParam, lParam) As sys
! GetDC             Lib "user32.dll"   (sys hwnd) As sys

! BeginPath         Lib "gdi32.dll"    (sys hdc) As sys
! TextOut           Lib "gdi32.dll"    Alias "TextOutA" (sys hdc,x,y,string lpString,sys nCount) As sys
! SetBkMode         Lib "gdi32.dll"    (sys hdc,nBkMode) As sys
! SetBkColor        Lib "gdi32.dll"    (sys hdc,crColor) As sys
! SetTextColor      Lib "gdi32.dll"    (sys hdc,crColor) As sys
! Rectangle         Lib "gdi32.dll"    (sys hdc,x1,y1,x2,y2) As sys
! Ellipse           Lib "gdi32.dll"    (sys hdc,x1,y1,x2,y2) As sys
! CreateSolidBrush  Lib "gdi32.dll"    (sys crColor) As sys
! SelectObject      Lib "gdi32.dll"    (sys hdc, hObject) As sys
! DeleteObject      Lib "gdi32.dll"    (sys hObject) As sys
! GetStockObject    Lib "gdi32.dll"    (sys nIndex)  As sys
 
string pw = "pw"
string hello = "DO YOU LIKE BANANA MICROSOFT ?"
string hellu = "DO YOU LIKE MICROSOFT BANANAS?"

Function WinProc(sys hWnd, iMsg, wParam, lParam) as sys callback

select imsg

   '
case WM_PAINT
   hdc = GetDC(hWnd)
   SelectObject hdc,GetStockObject(NULL_BRUSH)
   Rectangle hdc,150,190,420,240
   SetBkMode hdc,2
   SetTextColor hdc,255*256
   SetBkColor hdc,5198455
   TextOut hdc,160,200,Hello,Len(hello)
   SetBkMode hdc,1
   SetTextColor hdc,0
   TextOut hdc,160,216,Hellu,Len(hello)
   ReleaseDC hwnd,hdc
   'InvalidateRect hWnd,0,0

case WM_DESTROY
   PostQuitMessage 0

end select
       
Return DefWindowProc hWnd, iMsg, wParam, lParam
 
End Function   

MSG iMsg
WNDCLASS wc
sys hwnd, hInst

hInst = GetModuleHandle 0
wc.style = CS_HREDRAW or CS_VREDRAW
wc.lpfnWndProc  = &WinProc
wc.cbClsExtra   = 0
wc.cbWndExtra   = 0
wc.hInstance    = hInst
wc.hIcon        = LoadIcon   0,IDI_WINLOGO           
wc.hCursor      = LoadCursor 0,IDC_ARROW       
wc.hbrBackground= COLOR_WINDOW+1   
wc.lpszMenuName = 0
lea eax,pw
wc.lpszClassName = eax

RegisterClass wc
hWnd = CreateWindowEx 0,wc.lpszClassName,"o2Basic",WS_OVERLAPPED,50,50,640,480,0,0,hInst,0
ShowWindow hwnd, SW_SHOW

while GetMessage    iMsg,0,0,0
   iF iMsg.message= WM_QUIT Then Exit While
   TranslateMessage iMsg
   DispatchMessage  iMsg
wend