• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

DLL / Inputbox example + LionBasic :)

Started by Frank Brübach, September 28, 2009, 07:56:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

#15
right you are :)

simple mistake by wrong copying given some strange results, I am not really healthy, sorry. but now it's nearly all ok here for my first strike. thank you. your support helps even I have just a little little knowledge about things I can realize with powerbasic! I will use it at a later moment for thinbasic too (!) ;)

I have done in my last example little string output, so this chapter is ready for myself to take off for learning.


#COMPILER PBWIN 9
#COMPILE EXE
'--------------------------------------------------------------------
DECLARE FUNCTION MyFunction1 LIB "Lionbasic_DLL.DLL" _
         ALIAS "MyFunction1" (BYVAL Param1 AS LONG) AS LONG
'--------------------------------------------------------------------

'--------------------------------------------------------------------
DECLARE FUNCTION MySub1 LIB "Lionbasic_DLL.DLL" _
         ALIAS "MySub1" (BYVAL Param2 AS LONG, BYVAL a AS LONG, BYVAL b AS LONG, BYVAL c AS LONG) AS DOUBLE
'--------------------------------------------------------------------

'--------------------------------------------------------------------
DECLARE FUNCTION LionBasic_Test LIB "Lionbasic_DLL.DLL" _
         ALIAS "LionBasic_Test" (BYVAL Param3 AS LONG, BYVAL x AS LONG, BYVAL y AS LONG, BYVAL z AS LONG) AS DOUBLE
'--------------------------------------------------------------------

'--------------------------------------------------------------------
DECLARE FUNCTION Colorix LIB "Lionbasic_DLL.DLL" _
         ALIAS "Colorix" (BYVAL k AS DOUBLE) AS DOUBLE
'--------------------------------------------------------------------

'--------------------------------------------------------------------
DECLARE FUNCTION AddOne LIB "Lionbasic_DLL.DLL" _
         ALIAS "AddOne" (BYVAL x AS DOUBLE, BYVAL y AS DOUBLE) AS DOUBLE
'--------------------------------------------------------------------

'--------------------------------------------------------------------
DECLARE FUNCTION StringTest LIB "Lionbasic_DLL.DLL" _
ALIAS "StringTest" (BYVAL a AS STRING, BYVAL t AS DOUBLE) AS STRING
'--------------------------------------------------------------------

'--------------------------------------------------------------------
DECLARE FUNCTION windowME LIB "Lionbasic_DLL.DLL" _
ALIAS "windowME" (BYVAL hdlg AS DWORD) AS LONG
'--------------------------------------------------------------------

FUNCTION PBMAIN () AS LONG
   LOCAL lRes AS LONG
   LOCAL myResult AS LONG
   LOCAL d AS LONG
   LOCAL z AS LONG
   LOCAL v AS LONG
   LOCAL r AS LONG
   LOCAL q AS LONG
   LOCAL str AS STRING
   LOCAL windows AS LONG

   lRes = MyFunction1(lRes)
   d = MySub1(d,1,2,3)
   q = LionBasic_test(q,1,2,3)
   v  = Colorix(v)
   r = Addone(r,1)
   str = stringTest(str,1)
   windows = windowME(windows)


   MSGBOX "SuperHeroes.exe feedback result from first LIONBASIC.DLL:" + STR$(lRes), %MB_OKCANCEL, " ~Lionbasic TestScript " + DATE$
   MSGBOX "Not only SuperHeroes can calculate :) " + STR$(d), %MB_OK, " ~Lionbasic TestScript " + TIME$
   MSGBOX "Does Spiderman goes daily shopping with his girlfriend Anne? " + STR$(q), %MB_ICONQUESTION, " ~Lionbasic TestScript " + TIME$
   MSGBOX "ColorWoman shows you no string: " + STR$(v), %MB_ICONQUESTION, " ~Lionbasic ColorX TestScript " + STR$(v)
   'MSGBOX "calculate silly things: " + STR$(r), %MB_ICONQUESTION, " ~Lionbasic Addone Calc "
   MSGBOX "Tell me more secrets!: " & str, %MB_ICONQUESTION, " ~Lionbasic String Test "
   MSGBOX "Window_TestClipping: " + STR$(windows), %MB_ICONQUESTION, " ~Lionbasic WinApi Test: " + DATE$
END FUNCTION



only one problem will remain with this "addone" line:

MSGBOX "calculate silly things: " + STR$(r), %MB_ICONQUESTION, " ~Lionbasic Addone Calc "

I will check it next day. more to come. thanks for help.

last edit: - have made a little experiment and have included a "dialogue box" with "three buttons" (not yet any call back functions possible), with a usual function!  :)
don't know if this one can be valid too for a callback function for a separately function, I will try it tomorrow. must *laugh*. I am surprised. so this work increases for making a lot of fun!

good evening, servus and cheerio, frank

Frank Brübach

#16
good evening.

I have a problem to make a callback function in my LionbasicDLL.bas. I have this general question why it's not possible to make a callback function in this way ? the compiler gives several error messages, for example block statement are not allowed. I have tried to code this way, it's not perfect. I cannot make any callback function into this two function I have planned:

code part of *dll.bas:

'---------------------------------------
FUNCTION windowME ALIAS "windowME" (BYVAL hdlg AS DWORD) EXPORT AS LONG

  DIALOG NEW PIXELS , 0, " LionBasic Graphics_ButtonTest ",420,420,240,240, %WS_OVERLAPPEDWINDOW TO hDlg
  CONTROL ADD BUTTON , hDlg , 100," Don't push me ", 60,30,100,38
  CONTROL ADD BUTTON , hDlg , 120," Batman's not here! ", 60,80,100,38
  CONTROL ADD BUTTON , hDlg , 140," thinbasic+powerbasic! ", 50,128,120,48
  CONTROL ADD BUTTON , hDlg , 180," Graphics Power! ", 50,180,120,48
  CONTROL ADD BUTTON,  hDlg , 2, "Cancel", 5, 12, 50, 28
  CONTROL SET COLOR    hDlg, id&, RGB(100,250,100),RGB(200,0,100)
  CONTROL ADD LABEL,   hDlg, id&, "only for test purpose", 60, 4, 120, 12, , , _

  DIALOG SHOW MODAL hDlg '-- CALL DlgProc TO Result& doesn't work here !
  FUNCTION = hDlg
END FUNCTION
'---------------------------------------

FUNCTION callbackme ALIAS "callbackme" (BYVAL dlgProc AS DWORD) EXPORT AS LONG
     DIM s AS LONG
     DIM cbmsga AS LONG    '-- CBMSG doesn't work at all
     DIM CBHNDLs AS LONG   '-- CBHNDL doesn't work at all

     IF s ISTRUE THEN
     MSGBOX "hello",%MB_OK,"save our souls"
     IF CBMSGa = %WM_COMMAND THEN DIALOG END CBHNDLs
     END IF
     FUNCTION = CBMSGa
     'FUNCTION = CBHNDLs
END FUNCTION

'------------------------------------------


I know it's perhaps a unusual way, but I have tried it.

this cannot work, but why ?

  DIALOG SHOW MODAL hDlg '-- CALL DlgProc TO Result& doesn't work here !
           DIM cbmsga AS LONG    '-- CBMSG doesn't work at all
           DIM CBHNDLs AS LONG   '-- CBHNDL doesn't work at all


perhaps somebody can give a serious hint or advice. thanks in advance. I will solve this problem ;)
I want to close the dialogue by clicking one of the four buttons.


=> I am looking for a window procedure for the custom dialogue control.

best regards, frank
ps: test example attached

José Roca

#17
Quote
this cannot work, but why ?

1. CALL DlgProc must point to an existing callback function and you seem to think that it is a parameter to your (non callback) callbackme function.

2. The callback function must not be exported, since only Windows can call it.

3. All the code in your callbackme function is wrong. Use something like this:


CALLBACK FUNCTION DlgProc() AS LONG

  SELECT CASE CB.MSG

     CASE %WM_COMMAND
        ' -------------------------------------------------------------------
        ' Messages from controls and menu items are handled here.
        ' -------------------------------------------------------------------
        SELECT CASE CB.CTL
           CASE %IDCANCEL
              IF CB.CTLMSG = %BN_CLICKED THEN DIALOG END CB.HNDL, 0
           ' CASE ...
           ' CASE ...
        END SELECT

  END SELECT

END FUNCTION


4. Decide if you're going to use DDT or the SDK style programming. Using both at this stage, depending on the code you find, can only confuse you because they work differently.

Frank Brübach

#18
hi rosé, do you heard my laughing ?  ;D

Quote3. All the code in your callbackme function is wrong. Use something like this:

that's my personal reason for make it better and learn more about these things! I have a lot of humour ;)

1) thank you very mucho, because it's the first time I see such things!

I have fixed prompted my little dialogue box. It's just for testing and coming up one more step forward!
now it's possible to close the button (left top side little close button: "close").

2)
Quote4. Decide if you're going to use DDT or the SDK style programming. Using both at this stage, depending on the code you find, can only confuse you because they work differently.

!!! good to know !!!

DDT and SDK style or petzolds api they are working in a quite different way, I am thinking too. the usual dialogue boxes aren't very exciting for my purpose and ideas. but I have started with ddt example, doesn't matter. I like more the petzold look-a-like style. I will nerve you again if I am ready with the sdk or petzold api style with forthcoming DLL programming. so long.

best regards into the night to all here at the forum, frank

Frank Brübach

#19
hello.

I am looking for a very short way to create a own styled "sdk window" by using DLL power. I don't know how to do this complicated way, but I will search for a solution or somebody can help.

I have only managed this "graphic window" easiest way:


1) "xWinDLL".bas example:

#COMPILER PBWIN 9
#COMPILE DLL

%USEMACROS = 1
#INCLUDE "Win32API.inc"

GLOBAL ghInstance AS DWORD

'-------------------------------------------------------------------------------
' Main DLL entry point called by Windows...
'
FUNCTION LIBMAIN (BYVAL hInstance   AS LONG, _
                 BYVAL fwdReason   AS LONG, _
                 BYVAL lpvReserved AS LONG) AS LONG

   SELECT CASE fwdReason

   CASE %DLL_PROCESS_ATTACH

       ghInstance = hInstance
       FUNCTION = 1   'success!

   CASE %DLL_PROCESS_DETACH

       FUNCTION = 1   'success!
       'FUNCTION = 0   'failure!

   CASE %DLL_THREAD_ATTACH
       FUNCTION = 1   'success!

   CASE %DLL_THREAD_DETACH
       FUNCTION = 1   'success!

   END SELECT

END FUNCTION

FUNCTION Screen1 ALIAS "Screen1" (BYVAL X AS INTEGER, BYVAL Y AS INTEGER) EXPORT AS LONG
 ' Create and show a Graphic window on screen
     LOCAL hWin AS DWORD
     LOCAL k AS LONG
     LOCAL j AS LONG

     GRAPHIC WINDOW "BoxY", 300, 300, 220, 220 TO hWin
     GRAPHIC ATTACH hWin, 0

     FOR k& = 0 TO 255
     GRAPHIC LINE (0, k&) - (255, k&), RGB(255, 10, k&+50)
     NEXT
     FOR j& = 0 TO 255
     GRAPHIC LINE (j&, 0) - (j&, 255), RGB(j&, 100, 250)
     NEXT
     GRAPHIC WIDTH 1
     GRAPHIC STYLE 4
     GRAPHIC BOX (40, 40) - (120, 120), 20, %BLUE, 6

     SLEEP 5000

 FUNCTION = hWin
END FUNCTION
'



and here the

2) "test_xWinDLL.bas":
#COMPILER PBWIN 9
#COMPILE EXE


DECLARE FUNCTION Screen1 LIB "xWinDLL.dll" _
        ALIAS "Screen1" (BYVAL X AS INTEGER, BYVAL Y AS INTEGER) AS LONG

FUNCTION PBMAIN () AS LONG
   LOCAL lRes AS LONG
   LOCAL a AS LONG
   LOCAL b AS LONG
   LOCAL z AS LONG
   LOCAL t AS LONG
   b = 100000

   z = Screen1(z,t)

   MSGBOX "yes we have won this gold price: " + STR$(b), %MB_ICONINFORMATION, "hello Maria! she can calculate!"

END FUNCTION


works perfect. you will see a little graphic window with blue and red color effect.
I am sure this little code is useful and shows how powerful this kind of dll creation can be.

now it would be great to see or showing by an existing example how to manage a complicated sdk window dll. I am curious to see such thing ! I am doing more experiments and will get this interesting stuff !

best regards, frank

José Roca

 
The main window (dialog is not good terminology when speaking of SDK, same as script is not good terminology when speaking of a program written with a compiler), should reside in the application. Now, if you want to put the popup windows (or dialogs, if you prefer it), in a DLL, there is nothing difficult or mysterious: just do it!

Here is my previous example that created a popup window when you clicked the "Ok" button with the code for the popup placed in a DLL. Just load it in the editor and compile it to create the DLL (save the source file as PopupDlg,bas):


#COMPILE DLL
#INCLUDE "windows.inc"

' ========================================================================================
' Popup dialog - Calling example: ShowPopupDialog hWnd
' ========================================================================================
FUNCTION ShowPopupDialog ALIAS "ShowPopupDialog" (BYVAL hParent AS DWORD) EXPORT AS LONG

   LOCAL hWndPopup   AS LONG
   LOCAL hCtl        AS LONG
   LOCAL hFont       AS LONG
   LOCAL rc          AS RECT
   LOCAL wcex        AS WNDCLASSEX
   LOCAL szClassName AS ASCIIZ * 80
   LOCAL szCaption   AS ASCIIZ * 255

   hFont = GetStockObject(%ANSI_VAR_FONT)

   szClassName        = "MyPopupClassName"
   wcex.cbSize        = SIZEOF(wcex)
   wcex.style         = %CS_HREDRAW OR %CS_VREDRAW
   wcex.lpfnWndProc   = CODEPTR(PopupDlgProc)
   wcex.cbClsExtra    = 0
   wcex.cbWndExtra    = 0
   wcex.hInstance     = GetModuleHandle("")
   wcex.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
   wcex.hbrBackground = %COLOR_3DFACE + 1
   wcex.lpszMenuName  = %NULL
   wcex.lpszClassName = VARPTR(szClassName)
   wcex.hIcon         = 0
   wcex.hIconSm       = 0
   RegisterClassEx wcex

   GetWindowRect hParent, rc          ' For centering child in parent
   rc.nRight = rc.nRight - rc.nLeft   ' Parent's width
   rc.nBottom = rc.nBottom - rc.nTop  ' Parent's height

   szCaption = "Popup dialog"
   hWndPopup = CreateWindowEx(%WS_EX_DLGMODALFRAME OR %WS_EX_CONTROLPARENT, _
               szClassName, szCaption, %WS_CAPTION OR %WS_POPUPWINDOW OR %WS_VISIBLE, _
               rc.nLeft + (rc.nRight - 290) / 2, _
               rc.nTop + (rc.nBottom - 180) / 2, _
               290, 180, hParent, 0, GetModuleHandle(""), BYVAL %NULL)

   hCtl = CreateWindowEx(0, "BUTTON", "&Close", %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_FLAT, _
               200, 118, 75, 23, hWndPopup, %IDCANCEL, GetModuleHandle(""), BYVAL %NULL)
   IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

   ShowWindow hWndPopup, %SW_SHOW
   UpdateWindow hWndPopup
   ' Message handler loop
   LOCAL uMsg AS tagMsg
   WHILE GetMessage(uMsg, %NULL, 0, 0)
      IF ISFALSE IsDialogMessage(hWndPopup, uMsg) THEN
         TranslateMessage uMsg
         DispatchMessage uMsg
      END IF
   WEND

   FUNCTION = uMsg.wParam

END FUNCTION
' ========================================================================================

' ========================================================================================
' Popup dialog procedure
' ========================================================================================
FUNCTION PopupDlgProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG

   SELECT CASE wMsg
      CASE %WM_CREATE
         EnableWindow GetWindow(hWnd, %GW_OWNER), %FALSE   ' To make the popup dialog modal

      CASE %WM_COMMAND
         SELECT CASE LO(WORD, wParam)
            CASE %IDCANCEL
               IF HI(WORD, wParam) = %BN_CLICKED THEN
                  SendMessage hWnd, %WM_CLOSE, 0, 0
                  EXIT FUNCTION
               END IF
         END SELECT

      CASE %WM_CLOSE
         EnableWindow GetWindow(hWnd, %GW_OWNER), %TRUE  ' Maintains parent's zorder

      CASE %WM_DESTROY
         PostQuitMessage 0                ' This function closes the main window
         EXIT FUNCTION

   END SELECT

   FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)

END FUNCTION
' ========================================================================================


And this is the application that creates the main window and creates the popup:


#COMPILE EXE
#DIM ALL
#INCLUDE "windows.inc"

DECLARE FUNCTION ShowPopupDialog LIB "PopupDlg.DLL" ALIAS "ShowPopupDialog" (BYVAL hParent AS DWORD) AS LONG

' ========================================================================================
' Main
' ========================================================================================
FUNCTION WinMain (BYVAL hInstance AS DWORD, BYVAL hPrevInstance AS DWORD, BYVAL lpszCmdLine AS ASCIIZ PTR, BYVAL nCmdShow AS LONG) AS LONG

   LOCAL hWndMain    AS DWORD
   LOCAL hCtl        AS DWORD
   LOCAL hFont       AS DWORD
   LOCAL wcex        AS WNDCLASSEX
   LOCAL szClassName AS ASCIIZ * 80
   LOCAL rc          AS RECT
   LOCAL szCaption   AS ASCIIZ * 255
   LOCAL nLeft       AS LONG
   LOCAL nTop        AS LONG
   LOCAL nWidth      AS LONG
   LOCAL nHeight     AS LONG

   hFont = GetStockObject(%ANSI_VAR_FONT)

   ' Register the window class
   szClassName        = "MyClassName"
   wcex.cbSize        = SIZEOF(wcex)
   wcex.style         = %CS_HREDRAW OR %CS_VREDRAW
   wcex.lpfnWndProc   = CODEPTR(WndProc)
   wcex.cbClsExtra    = 0
   wcex.cbWndExtra    = 0
   wcex.hInstance     = hInstance
   wcex.hCursor       = LoadCursor (%NULL, BYVAL %IDC_ARROW)
   wcex.hbrBackground = %COLOR_3DFACE + 1
   wcex.lpszMenuName  = %NULL
   wcex.lpszClassName = VARPTR(szClassName)
   wcex.hIcon         = LoadIcon (%NULL, BYVAL %IDI_APPLICATION) ' Sample, if resource icon: LoadIcon(hInst, "APPICON")
   wcex.hIconSm       = LoadIcon (%NULL, BYVAL %IDI_APPLICATION) ' Remember to set small icon too..
   RegisterClassEx wcex

   ' Window caption
   szCaption = "SDK Main Window"

   ' Retrieve the size of the working area
   SystemParametersInfo %SPI_GETWORKAREA, 0, BYVAL VARPTR(rc), 0

   ' Calculate the position and size of the window
   nWidth  = (((rc.nRight - rc.nLeft)) + 2) * 0.75   ' 75% of the client screen width
   nHeight = (((rc.nBottom - rc.nTop)) + 2) * 0.70   ' 70% of the client screen height
   nLeft   = ((rc.nRight - rc.nLeft) \ 2) - nWidth \ 2
   nTop    = ((rc.nBottom - rc.nTop) \ 2) - (nHeight \ 2)

   ' Create a window using the registered class
   hWndMain = CreateWindowEx(%WS_EX_CONTROLPARENT, _           ' extended style
                             szClassName, _                    ' window class name
                             szCaption, _                      ' window caption
                             %WS_OVERLAPPEDWINDOW OR _
                             %WS_CLIPCHILDREN, _               ' window styles
                             nLeft, _                          ' initial x position
                             nTop, _                           ' initial y position
                             nWidth, _                         ' initial x size
                             nHeight, _                        ' initial y size
                             %NULL, _                          ' parent window handle
                             0, _                              ' window menu handle
                             hInstance, _                      ' program instance handle
                             BYVAL %NULL)                      ' creation parameters

   hCtl = CreateWindowEx(0, "BUTTON", "&Ok", %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_FLAT, _
          0, 0, 0, 0, hWndMain, %IDOK, hInstance, BYVAL %NULL)
   IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

   hCtl = CreateWindowEx(0, "BUTTON", "&Close", %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_FLAT, _
          0, 0, 0, 0, hWndMain, %IDCANCEL, hInstance, BYVAL %NULL)
   IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

   ' Show the window
   ShowWindow hWndMain, nCmdShow
   UpdateWindow hWndMain

   ' Message handler loop
   LOCAL uMsg AS tagMsg
   WHILE GetMessage(uMsg, %NULL, 0, 0)
      IF ISFALSE IsDialogMessage(hWndMain, uMsg) THEN
         TranslateMessage uMsg
         DispatchMessage uMsg
      END IF
   WEND

   FUNCTION = uMsg.wParam

END FUNCTION
' ========================================================================================

' ========================================================================================
' Main Window procedure
' ========================================================================================
FUNCTION WndProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG

   LOCAL rc AS RECT

   SELECT CASE wMsg

      CASE %WM_CREATE
         ' -------------------------------------------------------
         ' A good place to initiate things, declare variables,
         ' create controls and read/set settings from a file, etc.
         ' -------------------------------------------------------

      CASE %WM_SIZE
         ' ----------------------------------------------------------------------
         ' If you have a Toolbar and/or a Statusbar, send the following messages:
         ' SendMessage hStatusbar, wMsg, wParam, lParam
         ' SendMessage hToolbar, wMsg, wParam, lParam
         ' ----------------------------------------------------------------------

         ' Resize the two sample buttons of the dialog
         IF wParam <> %SIZE_MINIMIZED THEN
            GetClientRect hWnd, rc
            MoveWindow GetDlgItem(hWnd, %IDOK), (rc.nRight - rc.nLeft) - 185, (rc.nBottom - rc.nTop) - 35, 75, 23, %TRUE
            MoveWindow GetDlgItem(hWnd, %IDCANCEL), (rc.nRight - rc.nLeft) - 95, (rc.nBottom - rc.nTop) - 35, 75, 23, %TRUE
         END IF

      CASE %WM_COMMAND
         ' -------------------------------------------------------
         ' Messages from controls and menu items are handled here.
         ' -------------------------------------------------------
         SELECT CASE LO(WORD, wParam)

            CASE %IDOK
               IF HI(WORD, wParam) = %BN_CLICKED THEN
                  ShowPopupDialog(hwnd)
               END IF

            CASE %IDCANCEL
               IF HI(WORD, wParam) = %BN_CLICKED THEN
                  SendMessage hWnd, %WM_CLOSE, 0, 0
                  EXIT FUNCTION
               END IF

         END SELECT

      CASE %WM_CTLCOLORBTN, %WM_CTLCOLOREDIT, %WM_CTLCOLORLISTBOX, %WM_CTLCOLORSTATIC
         ' --------------------------------------------------------
         ' wParam is the handle of the control's display context (hDC)
         ' lParam is the handle of the control
         ' Example of how to set the colors of an specific control:
         ' --------------------------------------------------------
         ' IF lParam = GetDlgItem(hWnd, CtlId) THEN
         '    SetBkColor wParam, GetSysColor(%COLOR_INFOBK)
         '    SetTextColor wParam, GetSysColor(%COLOR_INFOTEXT)
         '    FUNCTION = GetSysColorBrush(%COLOR_INFOBK)
         '    EXIT FUNCTION
         ' END IF
         ' --------------------------------------------------------

      CASE %WM_SYSCOMMAND
         ' Capture this message and send a WM_CLOSE message
         IF (wParam AND &HFFF0) = %SC_CLOSE THEN
            SendMessage hWnd, %WM_CLOSE, 0, 0
            EXIT FUNCTION
         END IF

      CASE %WM_CLOSE
         ' --------------------------------------------------------
         ' The WM_CLOSE message is processed BEFORE the WM_DESTROY
         ' message and it can be used to confirm program exit or
         ' tasks like deallocating memory or similar tasks.
         ' --------------------------------------------------------

      CASE %WM_DESTROY
         ' ---------------------------------------------------------------------------
         ' Is sent when program ends - a good place to delete any created objects and
         ' store settings in file for next run, etc. Must send PostQuitMessage to end
         ' properly in SDK-style dialogs. The PostQuitMessage function sends a WM_QUIT
         ' message to the program's (thread's) message queue, and then WM_QUIT causes
         ' the GetMessage function to return zero in WINMAIN's message loop.
         ' ---------------------------------------------------------------------------
         PostQuitMessage 0    ' This function closes the main window
         EXIT FUNCTION

   END SELECT

   FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)

END FUNCTION
' ========================================================================================


The attached file contains the source code, the DLL and the EXE.

Frank Brübach

#21
hello jose.

QuoteNow, if you want to put the popup windows (or dialogs, if you prefer it), in a DLL, there is nothing difficult or mysterious: just do it!

It's just so easy ? thank you! Thought too complicated about winmain and popup dialogues and wanted to declare everything separately. I will create for next time new pb DLL example. And do it :)

best regards, frank