hey Frank
you give me idea how to create simple mouse GDI drawing program....
'gui-skeleton app
$ Filename "MouseDraw.exe"
Include "RTL32.inc"
Include "awinh.inc"
#lookahead
INT win,win2
INT x,y,w,h,x2,y2,w2,h2
x=0:y=10:w=400:h=400
x2=410:y2=10:w2=400:h2=300
INT winstyle,wstyle2
winstyle = WS_MINMAXSIZE or WS_CLIPCHILDREN
wstyle2 = WS_MINMAXSIZE or WS_CLIPCHILDREN
INT b0ID = 100
'##### GLOBALS ###############################################
INT hdc, hdcMem, hbmMem, oldBmp, oldBrush, oldPen, oldFont,fColor
INT textX,textY,hBrush
String tBuffer
INT mx,my,tx,ty,hx,hy,mode
'##############################################################
'create window **************************************************
win = SetWindow("Double Buffered Window",x,y,w,h,0,winstyle)
'print "WIN:" +str(win)
'create button on win
'button0 = SetButton(win,80,4,80,26,"Close Win2",0x50000000,0x200,b0ID)
'create second window
'****************************************************************
'init paint structure if you plan to use BeginPaint/EndPaint
'PAINTSTRUCT ps
InitDrawing()
'text
TextColor(win,RGB(220,0,0),RGB(231,223,231))
TextOn(win,40,20,"Draw on window...")
'/////////
Wait()
'\\\\\\\\\
Function WndProc (sys hwnd,wmsg,wparam,lparam) as sys callback
SELECT hwnd
'----------------------------------------
CASE win
'----------------------------------------
Select wmsg
CASE WM_CLOSE
DestroyWindow win
'Clean DC objects
CleanUp()
PostQuitMessage 0
CASE WM_SIZE
'get current size of window
GetSize(win,0,0,w,h)
',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
CASE WM_PAINT
' //blit under WM_PAINT - can be blited inside Message Loop to //
' blit the memory DC buffer back to the window DC
BitBlt(hDC, 0, 0, w, h, hdcMem, 0, 0, SRCCOPY)
'mousemove msg
CASE WM_MOUSEMOVE
hx=LoWord(lParam): hy=HiWord(lParam)
'call mouse h
hMouse( hx, hy)
'left Mbutton
CASE WM_LBUTTONDOWN
mode=1
tx= LoWord(lParam)
ty = HiWord(lParam)
MoveXY (win,tx,ty)
'right Mbutton
CASE WM_LBUTTONUP
mode=0
',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
CASE WM_COMMAND
controlID = LoWord(wParam) 'get control ID
notifyCode = HiWord(wParam) 'get notification message
Select controlID
CASE b0ID
If notifycode=0
MsgBox "Close New Window!","To Win2"
'CloseWindow(win2)
End If
End Select
End select
END SELECT
RETURN Default
END FUNCTION
'----------------------------------------------------
'drawm
SUB hMouse(mx as INT,my as INT)
IF mode=1
LineToXY (win,mx,my)
END IF
END SUB
SUB InitDrawing
''get current size of window
GetSize(win,0,0,w,h)
'get window DC
hdc=GetDC(win)
hdcMem = CreateCompatibleDC(0)
hbmMem = CreateCompatibleBitmap(hdc, w, h)
oldBmp = SelectObject( hdcMem, hbmMem )
oldBrush = SelectObject(hdcMem, CreateSolidBrush( RGB(231,223,231)) )
oldPen = SelectObject(hdcMem, CreatePen(PS_SOLID,1,RGB(231,223,231)))
'fill rectangle memDC with brush color
FillRect ( hdcMem,rc, oldBrush)
SetTextColor( hDC,RGB(0,0,0))
SetBkColor( hDC, RGB(231,223,231))
'blit to memDC
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( win, hdc)
End SUB
'##########################################################
SUB TextColor (wID as INT,byval frontColor as sys,byval backColor as sys )
hdc = GetDC(wID)
fColor=frontColor
SetTextColor( hDC, frontColor)
SetBkColor( hDC, backColor)
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( wID, hdc)
END SUB
'########################################################
SUB TextOn(wID as INT,tx as INT,ty as INT,byval txt as string)
hdc = GetDC(wID)
'draw text to screen DC
TextOut hdc,tx,ty,txt,Len(txt)
'blit screen DC to memDC
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( wID, hdc)
END SUB
'-------------------------------------------------
SUB Pset (wID as int , px as int ,py as int)
hdc = GetDC(wID)
SetPixel ( hdc, px, py, fColor)
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( wID, hdc)
END SUB
'----------------------------------------------------------------
SUB LineXY (wID as INT,Lx as INT,Ly as INT,Lx1 as INT,Ly1 as INT)
hdc = GetDC(wID)
SelectObject(hdc, CreatePen(PS_SOLID,1,fColor))
MoveToEx (hdc,Lx,Ly,ByVal 0)
LineTo (hdc,Lx1,Ly1)
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( wID, hdc)
END SUB
'--------------------------------------------------------------
SUB LineToXY (wID as INT,Lx1 as INT,Ly1 as INT)
hdc = GetDC(wID)
SelectObject(hdc, CreatePen(PS_SOLID,1,fColor))
'MoveToEx (hdc,Lx,Ly,ByVal 0)
LineTo (hdc,Lx1,Ly1)
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( wID, hdc)
END SUB
'------------------------------------------------------------
SUB MoveXY (wID as INT,Lx as INT,Ly as INT)
hdc = GetDC(wID)
SelectObject(hdc, CreatePen(PS_SOLID,1,fColor))
MoveToEx (hdc,Lx,Ly,ByVal 0)
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( wID, hdc)
END SUB
'----------------------------------
SUB CleanUp
DeleteDC(hdcMem)
DeleteObject(SelectObject(hdcMem, oldBrush))
DeleteObject(SelectObject(hdcMem, oldPen))
DeleteObject(SelectObject(hdcMem, oldBmp))
END SUB
X