Announcement

Collapse
No announcement yet.

SDK Programming

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

    SDK Programming

    I'm trying to learn SDK programming with PB/DLL 6.0 Can someone
    post a very basic example. I'm wanting to do something like this:

    Create a form with a button and a listbox and a textbox
    when the person clicks on the button it adds the valud of the
    textbox to the listbox.

    I already know about all the sendmessage values etc, I just
    don't know how to set everything up. I took at look at
    skelton.bas in the samples directory but it uses a resource
    script for the dialog. I'm wanting to make the controls by
    hand.

    Thanks

    ------------------
    -Greg
    -Greg
    [email protected]
    MCP,MCSA,MCSE,MCSD

    #2
    what am I doing wrong, notice that I am trying to display a dialog
    but I can't get a button to display... Thanks

    Code:
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
    #INCLUDE "commctrl.inc"
    
    GLOBAL  ghInstance AS LONG
    FUNCTION WINMAIN (BYVAL hInstance     AS LONG, _
                      BYVAL hPrevInstance AS LONG, _
                      lpCmdLine           AS ASCIIZ PTR, _
                      BYVAL iCmdShow      AS LONG) AS LONG
        LOCAL CLASSNAME AS ASCIIZ * 20: CLASSNAME = "TEST"
        LOCAL hWnd AS LONG
        LOCAL Msg AS tagMsg
        LOCAL CC1 AS INIT_COMMON_CONTROLSEX
        LOCAL wndclass AS WndClassEx
        LOCAL hmainIcon AS LONG
        CC1.dwSize=SIZEOF(CC1)
        CC1.dwICC=%ICC_WIN95_CLASSES
        InitCommonControlsEX CC1
        hmainIcon = LoadIcon(hInstance, "")
        wndclass.cbSize        = SIZEOF(WndClass)
        wndclass.style         = %CS_HREDRAW OR %CS_VREDRAW
        wndclass.lpfnWndProc   = CODEPTR(WndProc)
        wndclass.cbClsExtra    = 0
        wndclass.cbWndExtra    = 0
        wndclass.hInstance     = hInstance
        wndclass.hIcon         = hmainIcon
        wndclass.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
    
        wndclass.hbrBackground = CreateSolidBrush(GetSysColor(%COLOR_MENU))
        wndclass.lpszMenuName  = %NULL
        wndclass.lpszClassName = VARPTR(CLASSNAME)
        wndclass.hIconSm       = LoadIcon(hInstance, BYVAL %IDI_APPLICATION)
        RegisterClassEx wndclass
        ghInstance = hInstance
    
        hWnd = CreateWindowEx(0, CLASSNAME, "Form1", %WS_OVERLAPPEDWINDOW, %CW_USEDEFAULT, %CW_USEDEFAULT, %CW_USEDEFAULT, %CW_USEDEFAULT, %HWND_DESKTOP, %NULL, hInstance, BYVAL %NULL)
        ShowWindow hWnd, iCmdShow
        UpdateWindow hWnd
        
        WHILE GetMessage(Msg, %NULL, 0, 0)
            TranslateMessage Msg
            DispatchMessage Msg
        WEND
    
        FUNCTION = msg.wParam
    END FUNCTION
    
    FUNCTION WndProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
                      BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
    
        SELECT CASE wMsg
            CASE %WM_CREATE
                hWnd = CreateWindowEx(hWnd, "BUTTON", "Form1", %WS_OVERLAPPEDWINDOW, 500, 500, 500, 500, hWnd, %NULL, ghInstance, BYVAL %NULL)
                FUNCTION = 0: EXIT FUNCTION
            CASE %WM_DESTROY
                PostQuitMessage 0
                FUNCTION = 0: EXIT FUNCTION
        END SELECT
        FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
    END FUNCTION
    ------------------
    -Greg
    -Greg
    [email protected]
    MCP,MCSA,MCSE,MCSD

    Comment


      #3
      what am I doing wrong
      A lot. First of all, dwStyle and dwExstyle fields in CreateWindowEx.

      Code:
      HWND CreateWindowEx(
        DWORD dwExStyle,      // extended window style
        LPCTSTR lpClassName,  // registered class name
        LPCTSTR lpWindowName, // window name
        DWORD dwStyle,        // window style
        int x,                // horizontal position of window
        int y,                // vertical position of window
        int nWidth,           // window width
        int nHeight,          // window height
        HWND hWndParent,      // handle to parent or owner window
        HMENU hMenu,          // menu handle or child identifier
        HINSTANCE hInstance,  // handle to application instance
        LPVOID lpParam        // window-creation data
      );
      There are nice SDK samples from Petzold's book http://www.powerbasic.com/files/pub/pbwin/petzold.zip



      ------------------
      E-MAIL: [email protected]

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎