This may be an answer of "NO" but I thought I would ask anyways.
Is there a way to find the "Windows Handle" of a Dialog or Window that I created in one function so that it can be used in other functions? Without declaring my variable as global?....or IE: I know the Equates value for the Window, but if I need to get the Windows Handle outside the function it was created in, is there a way?
I know there are API's for current Window, next window etc, but to my knowledge they are for use of enumerating Windows. Which does me no good unless I know the Windows Handle I am looking for.
For example from PbForms
Any way to do what I am thinking? (probable answer is "NO") or in this case I am most likely stuck with a Global variable to hold the value?
One side question that could be interesting. Is it better to declare the variable for the Windows Handle to be declared as DWORD or as LONG?
From my knowledge both SDK and DDT return %NULL if the window could not be created, or the Handle to the Window if it could. But I never checked to see if the Handle value was always in the range of a DWORD or a LONG?
(maybe another mute question, but "Inquiring Minds what to know")
Is there a way to find the "Windows Handle" of a Dialog or Window that I created in one function so that it can be used in other functions? Without declaring my variable as global?....or IE: I know the Equates value for the Window, but if I need to get the Windows Handle outside the function it was created in, is there a way?
I know there are API's for current Window, next window etc, but to my knowledge they are for use of enumerating Windows. Which does me no good unless I know the Windows Handle I am looking for.
For example from PbForms
Code:
#PBFORMS CREATED V1.51 '------------------------------------------------------------------------------ ' The first line in this file is a PB/Forms metastatement. ' It should ALWAYS be the first line of the file. Other ' PB/Forms metastatements are placed at the beginning and ' end of "Named Blocks" of code that should be edited ' with PBForms only. Do not manually edit or delete these ' metastatements or PB/Forms will not be able to reread ' the file correctly. See the PB/Forms documentation for ' more information. ' Named blocks begin like this: #PBFORMS BEGIN ... ' Named blocks end like this: #PBFORMS END ... ' Other PB/Forms metastatements such as: ' #PBFORMS DECLARATIONS ' are used by PB/Forms to insert additional code. ' Feel free to make changes anywhere else in the file. '------------------------------------------------------------------------------ #COMPILE EXE #DIM ALL '------------------------------------------------------------------------------ ' ** Includes ** '------------------------------------------------------------------------------ #PBFORMS BEGIN INCLUDES #IF NOT %DEF(%WINAPI) #INCLUDE "WIN32API.INC" #ENDIF #PBFORMS END INCLUDES '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Constants ** '------------------------------------------------------------------------------ #PBFORMS BEGIN CONSTANTS [color=blue]%IDD_DIALOG1 = 101[/color] '<--- I know this value, but Windows Handle not known until the Window is created #PBFORMS END CONSTANTS '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Declarations ** '------------------------------------------------------------------------------ DECLARE CALLBACK FUNCTION ShowDIALOG1Proc() DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG #PBFORMS DECLARATIONS '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Main Application Entry Point ** '------------------------------------------------------------------------------ FUNCTION PBMAIN() ShowDIALOG1 %HWND_DESKTOP END FUNCTION '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** CallBacks ** '------------------------------------------------------------------------------ CALLBACK FUNCTION ShowDIALOG1Proc() SELECT CASE AS LONG CBMSG CASE %WM_INITDIALOG ' Initialization handler CASE %WM_NCACTIVATE STATIC hWndSaveFocus AS DWORD IF ISFALSE CBWPARAM THEN ' Save control focus hWndSaveFocus = GetFocus() ELSEIF hWndSaveFocus THEN ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 END IF CASE %WM_COMMAND ' Process control notifications SELECT CASE AS LONG CBCTL END SELECT END SELECT END FUNCTION '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Dialogs ** '------------------------------------------------------------------------------ FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG LOCAL lRslt AS LONG #PBFORMS BEGIN DIALOG %IDD_DIALOG1->-> [color=blue]LOCAL hDlg AS DWORD '<---Only valid in this function unless I make it global?[/color] DIALOG NEW hParent, "Dialog1", 70, 70, 201, 121, %WS_POPUP OR %WS_BORDER _ OR %WS_DLGFRAME OR %WS_THICKFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _ %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR %WS_CLIPSIBLINGS OR _ %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _ %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _ %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg #PBFORMS END DIALOG DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt #PBFORMS BEGIN CLEANUP %IDD_DIALOG1 #PBFORMS END CLEANUP FUNCTION = lRslt END FUNCTION '------------------------------------------------------------------------------
One side question that could be interesting. Is it better to declare the variable for the Windows Handle to be declared as DWORD or as LONG?
From my knowledge both SDK and DDT return %NULL if the window could not be created, or the Handle to the Window if it could. But I never checked to see if the Handle value was always in the range of a DWORD or a LONG?
(maybe another mute question, but "Inquiring Minds what to know")
Comment