Seite 1 von 1

#PB_any mit WinApi

Verfasst: 24.08.2006 23:46
von Konne
Hallo wie kann ich eine ID für CreateWindowEx ermitteln die noch nicht existiert?

Verfasst: 25.08.2006 04:17
von edel
Gibt kein 'PB_Any' fuer die WinApi.

Verfasst: 25.08.2006 08:34
von NicTheQuick
CreateWindowEx gibt die dir doch ein handle zurück. Und das ist deine
einmalige ID.

Verfasst: 25.08.2006 09:01
von ts-soft
Simples Beispiel:

Code: Alles auswählen

; HWND CreateWindowEx(          DWORD dwExStyle,
;     LPCTSTR lpClassName,
;     LPCTSTR lpWindowName,
;     DWORD dwStyle,
;     int x,
;     int y,
;     int nWidth,
;     int nHeight,
;     HWND hWndParent,
;     HMENU hMenu,
;     HINSTANCE hInstance,
;     LPVOID lpParam
; );
Global Button1.l, hWndParent.l, hInstance.l

Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
  Result = #PB_ProcessPureBasicEvents
  
  Select Message
    Case #WM_COMMAND
      Select lParam
        Case Button1
          Debug "Button1"
      EndSelect
  EndSelect
  
  ProcedureReturn Result
EndProcedure

If OpenWindow(0, #PB_Ignore, 0, 150, 50, "TestFenster")
  

  hWndParent = WindowID(0) ; Parent ist das Hauptfenster
  hInstance = GetModuleHandle_(0)
  
  Button1 = CreateWindowEx_(#Null, "Button", "Drück mich", #WS_CHILD | #WS_VISIBLE, 35, 10, 80, 25, hWndParent, 0, hInstance, #Null)
  
  SetWindowCallback(@MyWindowCallback(), 0)
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Verfasst: 25.08.2006 20:07
von Konne
Mit ID meine ich:
HMENU hMenu,

Verfasst: 25.08.2006 20:19
von ts-soft
Konne hat geschrieben:Mit ID meine ich:
HMENU hMenu,
hMenu ist normallerweise #NULL
Ansonsten wird es nur für Dialogfenster gebraucht, PB erstellt aber nur
Windows, keine Dialogfenster. Diese ID bekommste mit GetDlgCtrlID_ vom
übergeordneten Control, wovon Deins Parent sein soll. Für mich höchst
unwahrscheinlich das sowas für PB gebraucht wird
:wink: