Announcement

Collapse
No announcement yet.

SDK Hellowin EXTRA

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SDK Hellowin EXTRA

    Hi guys,

    I post this in the hope other's can learn from it.
    This is the way I understand it now.

    Code:
    FUNCTION WinMain (BYVAL hInstance     AS DWORD, _        ' recieves this apllication unique handle
                      BYVAL hPrevInstance AS DWORD, _        ' not used in 32 bits windows always 0 
                      BYVAL lpCmdLine     AS ASCIIZ PTR, _   ' pointer to cmdline (gives only the params not path etc)
                      BYVAL nCmdShow      AS LONG) AS LONG   ' calling proggie can do for example  % sw_normal or %sw_minimize
    
    
       LOCAL  szAppName  AS ASCIIZ * 80 : szAppName = "HelloWin"
       LOCAL  hWnd       AS DWORD
       LOCAL  Msg		   AS tagMsg                           ' Msg struct for message pump
       LOCAL  wClass     AS WndClassEx                       ' WndClassEx struct
    
       wClass.cbSize        = SIZEOF(wClass)
       wClass.style         = %CS_HREDRAW OR %CS_VREDRAW     ' Redraws whole window if height/width changes or win is moved
       wClass.lpfnWndProc   = CODEPTR(WinProc)               ' set the target address for the message pump
       wClass.cbClsExtra    = 0
       wClass.cbWndExtra    = 0
       wClass.hInstance     = hInstance
       wClass.hIcon         = LoadIcon(%NULL, BYVAL %IDI_APPLICATION)
       wClass.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
       wClass.hbrBackground = CreateHatchBrush(%HS_CROSS, &H0FFFF11&)  ' use this brush for background
       wClass.lpszMenuName  = %NULL
       wClass.lpszClassName = VARPTR(szAppName)
       wClass.hIconSm       = LoadIcon(%NULL, BYVAL %IDI_APPLICATION)
    
       RegisterClassEx wClass                                ' register our class (wClass) for use with CreateWindowEx
    
    
       hWnd = CreateWindowEx( _
                            %WS_EX_LEFT, _                   ' extended style (now default)
                            szAppName, _                     ' window class name
                            "The Hello Program Extra", _     ' window caption
                            %WS_OVERLAPPEDWINDOW, _          ' window style
                            10, _                            ' left position
                            50, _                            ' top  position
                            640, _                           ' our window width
                            400, _                           ' our window height
                            %NULL, _                         ' parent window handle
                            %NULL, _                         ' window menu handle
                            hInstance, _                     ' program instance handle
                            BYVAL %NULL) 					      ' creation parameters
    
       local hBtn as long
       hBtn = CreateWindowEx( _
                            0, _
                            "BUTTON", _
                            "Test", _
                            %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
                            100,100,80,25, _
                            hWnd, _
                            100, _
                            hinstance, _
                            BYVAL %NULL)
    
    
       hBtn = CreateWindowEx( _
                            0, _
                            "BUTTON", _
                            "Test2", _
                            %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
                            200,100,80,25, _
                            hWnd, _
                            200, _
                            hinstance, _
                            BYVAL %NULL)
       
    
       ShowWindow hWnd, %SW_NORMAL                           ' Show the window with nCmdShow style(s)
       UpdateWindow hWnd                                     ' Triggers a WM_PAINT
    
       DO WHILE GetMessage(Msg, %NULL, 0, 0) > 0             ' Getmessage result can be -1
          TranslateMessage Msg
          DispatchMessage Msg
       LOOP
    
       FUNCTION = msg.wParam
    END FUNCTION
    
    FUNCTION WinProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
    
       LOCAL hDC AS DWORD
       LOCAL pS	 AS PAINTSTRUCT
       LOCAL rct AS RECT
    
       SELECT CASE  AS LONG wMsg                             ' use (force) integer testing for messages
          CASE %WM_CREATE
    
    	   CASE %WM_PAINT
    	      hDC = BeginPaint(hWnd, ps)                      ' set paint struct
             GetClientRect hWnd, rct                         ' recieve window left,top, right, bottom coordinates
             DrawText _                                      '
                hDC, _                                       ' device context handle
                "Hello, WindBlows!"+chr$(0), _               ' null terminated string otherwise pointer to string
                -1, _                                        ' the textlenght, if -1 then must be a null terminated string
                rct, _                                       ' the rectangle to paint in
                %DT_SINGLELINE	OR %DT_CENTER OR %DT_VCENTER  ' singleline centered hor. and vertical
             EndPaint hWnd, ps
             FUNCTION = 0                                    ' tell os that we did handle this msg
             EXIT FUNCTION
    
          CASE %WM_COMMAND
             SELECT CASE LOWRD(wParam)
                CASE 100
                   IF HIWRD(wParam) = %BN_CLICKED  THEN
                      MsgBox "Button1 Clicked",,""
                      FUNCTION=0
                   END IF
                CASE 200
                   IF hiwrd(WpARAM) = %BN_CLICKED THEN
                      MsgBox "Button2 Clicked",,""
                      FUNCTION=0
                   END IF
             END SELECT
    	   CASE %WM_DESTROY                                   ' our main window is already gone, clean up here and terminate the msg-pump
             PostQuitMessage 0                               ' this will give our msg-pump a 0 so the while wend stops
             FUNCTION = 0
             EXIT FUNCTION
       END SELECT
    
       FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)  ' not for us so give control to main msg pump
    
    END FUNCTION
    To Ask or Not To Ask ?

  • #2
    Adrian,

    As a registered user of the José Roca's forum, you can study the examples i have posted there

    Try to use them in order from [SDK] 1 to 15

    ...
    Patrice Terrier
    www.zapsolution.com
    www.objreader.com
    Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

    Comment


    • #3
      Hi Patrice,

      Already did, and I must say your code was a bit over the hill for me
      So first I did was pick up from the start, now I can read your code much better already, the samples you put at Jose Roca place are GOLD!
      But still I am making my own skin routines, atm I have a double buffer window skin runnning fine, now busy with the button control, then the static etc.
      Then when I match up in knowlegde again Patrice i will go study the GDI+ way again.
      I could off course copy your routines now change them a bit and use them , but to be honest thats the easy way out.
      I want to fully understand first Patrice , so I can match up with your guys instead of just playing copycat!
      To Ask or Not To Ask ?

      Comment


      • #4
        I want to fully understand first Patrice , so I can match up with your guys instead of just playing copycat!
        That's the good road to take to teach yourself
        Patrice Terrier
        www.zapsolution.com
        www.objreader.com
        Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

        Comment


        • #5
          Gotta love someone willing to learn
          And even better, wonder if one way is better than the other? or if one just "Makes more Sense" to them than the other.

          And then move on to "Here's how I understand it"

          I also love how people like Patrice and Pierre, and Jose post what they have, and how they did it, and comparing and working my own until the thought hits..."Hey didn't MSDN say you could do this idea instead of that????" and offer it up as I can.....

          Sharing is knowledge...and KNOWLEDGE is POWER!!!

          Keep it up all.....I would be NOWHERE without you guys, and still programming in VB being oblivious to other options that were even possible, till I saw it was done.
          Engineer's Motto: If it aint broke take it apart and fix it

          "If at 1st you don't succeed... call it version 1.0"

          "Half of Programming is coding"....."The other 90% is DEBUGGING"

          "Document my code????" .... "WHYYY??? do you think they call it CODE? "

          Comment

          Working...
          X