Announcement

Collapse
No announcement yet.

SDK Style Program Series Started In Source Code For Beginners

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

  • SDK Style Program Series Started In Source Code For Beginners

    just put two sample programs in source code forum that i hope will help
    folks get started with win32 sdk/api style coding with powerbasic's
    windows gui compilers. each program is simple and i tried to provide
    some very basic explanation for the major points of what is happening.
    i'm willing to add several more programs to the series of gradually
    increasing complexity and size if feedback is positive and of help to
    anyone. naturally, any feedback is welcome.

    the link in source code is
    http://www.powerbasic.com/support/pb...ad.php?t=25174

    ------------------
    fred

    [this message has been edited by fred harris (edited august 22, 2007).]
    Fred
    "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

  • #2
    Can you provide an email address for that feedback?

    I don't think you want everyone and his brother-in-law commenting - with possibly conflicting suggestsions -in some big long thread.

    Better I think for you to filter out those responses and decide what gets posted.

    If you don't want to do that, at least send <U>me</U> an address, because I saw two things in there which I would definitely counsel against most vigorously.

    mailto:[email protected][email protected]</A>

    [added]
    (No, I do not mean the GLOBAL variables. I mean two other things.)
    [/added]




    [This message has been edited by Michael Mattias (edited July 16, 2006).]
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Originally posted by Fred Harris:
      ...sample programs...that I hope will help
      folks get started with Win32 SDK/Api style coding with PowerBasic's
      windows GUI compilers....
      Fred thank you.

      There is definitively a serious shortage of real examples programs/tutorials with PBWin "specially designed" for a newbie like my self.

      Good on you.

      Guy

      ------------------
      Private Website:
      Guy's Website -
      SMS me on 0405 161 366 Brisbane, Australia

      [This message has been edited by G North (edited July 17, 2006).]
      Private Website:
      Guy's Website -
      Brisbane, Australia

      Comment


      • #4
        Yes, yes, yes! Please Fred, pour it on!

        I just came across this thread and am glad to see it as well.

        Cheers and thanks Fred. This is a great augment to my learning
        DDT with Stan.

        Cheers!

        ------------------

        Comment


        • #5
          Hello Fred,

          Fred, keep doing what you are doing.

          Guys like me would benefit from this. For I have never
          used the SDK style of programming and I'd love to learn.
          Been using DDT.

          Besides one has not been able to lay hands on Charles Petzold
          book (programming windows).

          Cheers,

          ------------------
          Fredrick Ughimi
          www.meganetcomputers.net
          mailto:[email protected][email protected]</A>
          - Imagination is more important than knowledge - Einstein.
          [This message has been edited by Fredrick Ughimi (edited October 15, 2006).]
          Fredrick Ughimi
          www.meganetsoft.com

          Comment


          • #6
            And Fred, you thought that we weren't peaking!

            And Fredrick, if you do a search through amazon.com, you should
            be able to get a copy of the petzold book used.

            Frank.

            ------------------

            Comment


            • #7
              Glad its helping. I'll periodically add to it, so check in
              occasionally.



              ------------------
              Fred
              "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"
              Fred
              "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

              Comment


              • #8
                Fred,

                I cannot find where you have posted your demos and this is after
                doing a forum search on your name. Do you have a link ?

                Regards,

                hutch at movsd dot com

                ------------------
                hutch at movsd dot com
                The MASM Forum - SLL Modules and PB Libraries

                http://www.masm32.com/board/index.php?board=69.0

                Comment


                • #9
                  steve,

                  not aweful far from beginning (august posts). here is the
                  link.
                  http://www.powerbasic.com/support/pb...ad.php?t=25174

                  be glad if you'd take a look and make some comments.



                  ------------------
                  fred
                  "fharris"+chr$(64)+"evenlink"+chr$(46)+"com"
                  Fred
                  "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                  Comment


                  • #10
                    Compliments Fred,

                    nice clean authodox Windows API code and I have no doubt that many
                    will find clear explanation very helpful. DDT works fine but API
                    code comes close to the bare metal and with just a bit of attention
                    it generally comes in smaller.

                    There is some virtue in explaining the order of startup with a normal
                    CreateWindowEx() window as the concept is very useful for someone who
                    is studying the code to get it going.

                    I will just note them in order as reference.

                    1. Fill the WNDCLASSEX structure for the following RegisterClassEx()
                    function call.

                    2. Call RegisterClassEx() to register the window class with the attributes
                    specified in the WNDCLASSEX structure.

                    3. Call the CreateWindowEx() function specifying the window size,
                    location and style to be created.

                    4. Document that CreateWindowEx() BEFORE IT RETURNS branches to the
                    WndProc function and processes the WM_CREATE message.

                    5. The window is then displayed using a combination of ShowWindow()
                    and UpdateWindow().

                    6. The details and operations of the message loop.
                    (a) Continue to loop until GetMessage() returns ZERO.
                    (b) What TranslateMessage() does if keyboard actions are present.
                    (c) How DispatchMessage() works by pointing certain ranges of
                    messages to the WndProc.

                    7. Explain that the WndProc() function is an OS defined callback
                    function that is called by the OS, never by the application.

                    There are a heap of people who are members who know their way around
                    API programming so I have no doubt that if you need any help or
                    alternate views on how to do a particular task that you can find it
                    here.

                    Keep up the good work.

                    Regards,

                    hutch at movsd dot com

                    ------------------
                    hutch at movsd dot com
                    The MASM Forum - SLL Modules and PB Libraries

                    http://www.masm32.com/board/index.php?board=69.0

                    Comment


                    • #11
                      Fred,

                      I have been recently working on template design for the current
                      version of PBwin 80 so I gutted one and added a collection of
                      msgboxs to show what I suggested above. It has a conditional
                      compile option so you can turn off the msgboxs to see the build
                      size of the PB compiler when using API code.

                      An empty pbmain as follows builds at 5120 bytes. This includes
                      dynamic string and array support, thread safe code support, error
                      handling and exit cleanup code.
                      Code:
                      FUNCTION PBmain as LONG
                      
                      End FUNCTION
                      The following template with the msgboxs turned off builds at 6656
                      bytes which shows the efficiency of pure API code which takes an
                      additional 1.5k of code to build a working window.

                      Code:
                      ' «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
                      
                          %USEMACROS = 1
                      
                        ' -----------------------------------------------------------------
                        ' set the following equate to 0 to see how small PB builds API code
                        ' -----------------------------------------------------------------
                          %msgboxes = 1
                      
                          #INCLUDE "h:\pbwin80\INCLUDE\WIN32API.INC"
                      
                          GLOBAL hInstance   as LONG
                          GLOBAL hWnd        as LONG
                          GLOBAL hIcon       as LONG
                      
                      ' «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
                      
                      FUNCTION PBmain() AS LONG
                      
                          LOCAL  Msg            as tagMSG
                          LOCAL  wc             as WNDCLASSEX
                          LOCAL  szClassName    as ASCIIZ * 32
                          LOCAL  DisplayName    as ASCIIZ * 32
                      
                          DisplayName = "PowerBASIC Demo"
                          szClassName = "PB_Class"
                      
                          hInstance   = GetModuleHandle(ByVal %NULL)
                      
                          #IF %msgboxes
                            msgbox "Instance handle = " + hex$(hInstance,8),0, _
                                   "The module's start address"
                          #ENDIF
                      
                          hIcon = LoadIcon(%NULL,ByVal %IDI_APPLICATION)
                      
                          wc.cbSize        = SIZEOF(wc)
                          wc.style         = %CS_BYTEALIGNCLIENT or %CS_BYTEALIGNWINDOW
                          wc.lpfnWndProc   = CODEPTR(WndProc)
                          wc.cbClsExtra    = 0
                          wc.cbWndExtra    = 0
                          wc.hInstance     = hInstance
                          wc.hIcon         = hIcon
                          wc.hCursor       = LoadCursor(%NULL,ByVal %IDC_ARROW)
                          wc.hbrBackground = %COLOR_BTNFACE + 1
                          wc.lpszMenuName  = %NULL
                          wc.lpszClassName = VarPtr(szClassName)
                          wc.hIconSm       = hIcon
                      
                          #IF %msgboxes
                            msgbox "Register the window class after filling out the WNDCLASSEX structure"
                          #ENDIF
                      
                          RegisterClassEx wc
                      
                          #IF %msgboxes
                            msgbox "Create the main window with CreateWindowEx()"
                          #ENDIF
                      
                          hWnd = CreateWindowEx( _
                                       %WS_EX_LEFT, _         ' extended style
                                       szClassName, _         ' window class name
                                       DisplayName, _         ' window title
                                       %WS_OVERLAPPEDWINDOW, _' windows styles
                                       %CW_USEDEFAULT, _      ' initial x position
                                       %CW_USEDEFAULT, _      ' initial y position
                                       %CW_USEDEFAULT, _      ' initial x size
                                       %CW_USEDEFAULT, _      ' initial y size
                                       %NULL, _               ' parent window handle
                                       %NULL, _               ' window menu handle
                                       hInstance, _           ' program instance handle
                                       ByVal %NULL)           ' creation parameters
                      
                          #IF %msgboxes
                            msgbox "hWnd = " + str$(hWnd),0,"CreateWindowEx() return value"
                          #ENDIF
                      
                          ShowWindow hWnd, %SW_SHOW
                          UpdateWindow hWnd
                      
                          #IF %msgboxes
                            msgbox "Enter the message loop"
                          #ENDIF
                      
                          While GetMessage(Msg,0,0,0) <> 0
                            TranslateMessage Msg
                            DispatchMessage  Msg
                          Wend
                      
                        FUNCTION = Msg.wParam
                      
                      END FUNCTION
                      
                      ' «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
                      
                      FUNCTION WndProc(ByVal hWin   as LONG, _
                                       ByVal Msg    as LONG, _
                                       ByVal wParam as LONG, _
                                       ByVal lParam as LONG) as LONG
                      
                          Select Case as LONG Msg
                      
                            Case %WM_CREATE
                              #IF %msgboxes
                                msgbox "CreateWindowEx() calls the WndProc before it returns", _
                                       0,"Hi from WM_CREATE"
                              #ENDIF
                      
                            Case %WM_CLOSE
                              #IF %msgboxes
                                msgbox "Last chance to clean up before exiting",0,"WM_CLOSE here"
                              #ENDIF
                      
                            Case %WM_DESTROY
                              #IF %msgboxes
                                msgbox "About to post the QUIT message to the"+chr$(13,10)+ _
                                       "GetMessage() function in the message loop",0,"WM_DESTROY here"
                              #ENDIF
                      
                              PostQuitMessage 0
                      
                          END Select
                      
                          FUNCTION = DefWindowProc(hWin,Msg,wParam,lParam)
                      
                      END FUNCTION
                      
                      ' «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
                      Regards,

                      hutch at movsd dot com


                      ------------------
                      hutch at movsd dot com
                      The MASM Forum - SLL Modules and PB Libraries

                      http://www.masm32.com/board/index.php?board=69.0

                      Comment


                      • #12
                        Hutch,

                        Thanks for looking at it and for the comments. I liked your
                        demo. I'll link this thread in with the programs in 'Source
                        Code' so anyone who finds it will also be directed to this
                        thread and your template too.





                        ------------------
                        Fred
                        "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"
                        Fred
                        "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                        Comment


                        • #13
                          Hello Frank,

                          >>And Fredrick, if you do a search through amazon.com, you should
                          be able to get a copy of the petzold book used.

                          Sure. But I ve problems paying for it. I live in Africa and paying
                          for stuffs in dollors or Euro from here is quite difficult and
                          when possible you might end up four times the real amount.

                          Does anyone have an old edition (Programming Windows BY Charles Petzold)
                          that he would like to send to me?

                          Best regards,



                          ------------------
                          Fredrick Ughimi
                          www.meganetcomputers.net
                          mailto:[email protected][email protected]</A>
                          - Imagination is more important than knowledge - Einstein.
                          Fredrick Ughimi
                          www.meganetsoft.com

                          Comment


                          • #14
                            Fredrick

                            ------------------
                            Fred
                            "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"
                            Fred
                            "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                            Comment


                            • #15
                              Fredrick

                              Just checked at Amazon and in the used books one is
                              listed for just 40 cents! I'm sure the postage would run
                              you some though.



                              ------------------
                              Fred
                              "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"
                              Fred
                              "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                              Comment


                              • #16
                                fredrick,

                                persoanlly i like rector and newcomer better, easier to understand and much better referance,

                                see, win32 reference books: http://www.powerbasic.com/support/pb...hread.php?t=39

                                2. rector and newcomer
                                "win32 programming", isbn: 0-201-63492-9

                                and the sdk, is even better than that, and can be gotten on-line for free, at microsoft.com

                                ------------------
                                washington dc area
                                borje's "poff's" is likely the best tool for learning pb.. http://www.tolkenxp.com/pb
                                and a few pbtool's & beginner help:http://sweetheartgames.com/pbtools/jumpstart.html
                                & another good resource: http://www.fredshack.com/docs/powerbasic.html

                                Comment


                                • #17
                                  I agree with Brad. The Rector and Newcomer book is my favorite as
                                  well. It even deals with Common Controls in sufficient depth. It is
                                  well worth the money and I am very happy that I bought it.




                                  ------------------
                                  Paul Squires
                                  FireFly Visual Designer, Cheetah Database System, JellyFish Pro Editor
                                  www.planetsquires.com
                                  Paul Squires
                                  FireFly Visual Designer (for PowerBASIC Windows 10+)
                                  Version 3 now available.
                                  http://www.planetsquires.com

                                  Comment


                                  • #18
                                    Hello Guys,

                                    Thanks alot for your response.

                                    Fred,

                                    Yeah, I ve seen those before. Its not actually the cost,
                                    but paying for it is the problem.

                                    Brad and Paul,

                                    Thanks for recommending Rector and Newcomer.

                                    Sure would get that also as soon as I am able to make payment.

                                    Best regards,




                                    ------------------
                                    Fredrick Ughimi
                                    www.meganetcomputers.net
                                    mailto:[email protected][email protected]</A>
                                    - Imagination is more important than knowledge - Einstein.
                                    Fredrick Ughimi
                                    www.meganetsoft.com

                                    Comment


                                    • #19
                                      I guess its been over a year ago or so the way time flys that I
                                      started my little tutorial on Windows programming using the
                                      Application Programming Interface ( Win32 Api ). Lately I've
                                      done considerably more work adding to and re-writting earlier posts,
                                      rather than writting new ones (particularly the first and second -
                                      I've completely scrapped the originals). Today, however, I added
                                      the eleventh. So its not really a 'little' tutorial anymore.

                                      Since sometime last winter I occasionally receive an email from
                                      someone who is finding the material useful, and that gives me
                                      inspiration to not give it up.

                                      ------------------
                                      Fred
                                      "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                                      [This message has been edited by Fred Harris (edited August 18, 2007).]
                                      Fred
                                      "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                                      Comment


                                      • #20
                                        How can I copy and paste the source from this tutorial, and other source from this forum? When I copy and paste it I get no line terminator at all.

                                        Also, as I'm entering this text I get no word wrap. A lot of posts that I read in this forum also have no word wrap.

                                        I'm using IE 7. I don't have this problem in other forums.

                                        Any help or suggestions will be much appreciated.

                                        Barry


                                        ------------------

                                        Comment

                                        Working...
                                        X