COMPILE EXE
#DIM ALL
#REGISTER NONE
#INCLUDE "win32api.inc"
%IDC_LABEL = 100
%IDC_TEXT = 101
DECLARE CALLBACK FUNCTION DlgProc
FUNCTION PBMAIN
LOCAL hDlg AS LONG
DIALOG NEW 0, "Example",,,115, 70, %DS_CENTER TO hDlg
CONTROL ADD LABEL, hDlg, %IDC_LABEL, "Add Text:",5,5,100,14
CONTROL ADD TEXTBOX, hDlg, %IDC_TEXT, "",5,15,100,14
CONTROL ADD BUTTON, hDlg, %IDOK, "&OK",5,35,40,14
CONTROL ADD BUTTON, hDlg, %IDCANCEL, "&Cancel",65,35,40,14
DIALOG SHOW MODAL hDlg CALL DlgProc
END FUNCTION
CALLBACK FUNCTION DlgProc
LOCAL s AS STRING
SELECT CASE CBMSG
CASE %WM_INITDIALOG
CASE %WM_COMMAND
SELECT CASE LOWRD(CBWPARAM)
CASE %IDOK
CONTROL GET TEXT CBHNDL, %IDC_TEXT TO s
IF s = "" THEN
MSGBOX "There is no text!",,"Example"
ELSE
DIALOG END CBHNDL
MSGBOX "The text is:" & $CR & s,,"Example"
MSGBOX "Thank You for using Example",,"Example"
END IF
CASE %IDCANCEL
DIALOG END CBHNDL
END SELECT
END SELECT
END FUNCTION
I have questons about parts of this program and what they do.
WHAT DO THIS TWO LINE LET ME DO?
#DIM ALL
#REGISTER NONE
IN THE LINE
CONTROL ADD TEXTBOX, hDlg, %IDC_TEXT, "",5,15,100,14
1. hDlg is set as a long in Function PBMAIN
but it not defind in Callback FUNCTION DlgProc
can this be replaced with with a an verible?
The book has hDlg& = Handle of the dialog in wich the button will be created
So that is pre defind can't be sub with any other name so is it that
you have to declerd it "LOCAL hDlg AS LONG"
2. This line uses %IDC_TEXT in this book in the syntax has this
as unique identifier for the control it is set up to 101 in this
example. what dose this control?
3. DIALOG SHOW MODAL hDlg CALL DlgProc
I think this is call function DlgProc that is defind as a CALLBACK
and pass hDlg to that function. am I right?
4. In every program I see there is two Functions. I understand
PBMAIN wich is like main function in c++. but the CALLBACK FUNCTION
Dose it have to be a CALLBACK FUNCTION? It seems to me that
CALLBACK is a type of FUNCTION what is the this meen?
5. what do this case do and what dose two verbal have stored
in them?
CASE %WM_INITDIALOG
CASE %WM_COMMAND
SELECT CASE LOWRD(CBWPARAM)
6. in the line CONTROL GET TEXT CBHNDL, %IDC_TEXT TO s
what dose CBHNDL do? Is it some type of veribale it use elsewhere in the
7. what DIALOG END CBHNDL DO?
Sorry so long with the questons. I just like to usdersand every part of
a program so I can use part in other programs thanks for all your
help
Joe
------------------
#DIM ALL
#REGISTER NONE
#INCLUDE "win32api.inc"
%IDC_LABEL = 100
%IDC_TEXT = 101
DECLARE CALLBACK FUNCTION DlgProc
FUNCTION PBMAIN
LOCAL hDlg AS LONG
DIALOG NEW 0, "Example",,,115, 70, %DS_CENTER TO hDlg
CONTROL ADD LABEL, hDlg, %IDC_LABEL, "Add Text:",5,5,100,14
CONTROL ADD TEXTBOX, hDlg, %IDC_TEXT, "",5,15,100,14
CONTROL ADD BUTTON, hDlg, %IDOK, "&OK",5,35,40,14
CONTROL ADD BUTTON, hDlg, %IDCANCEL, "&Cancel",65,35,40,14
DIALOG SHOW MODAL hDlg CALL DlgProc
END FUNCTION
CALLBACK FUNCTION DlgProc
LOCAL s AS STRING
SELECT CASE CBMSG
CASE %WM_INITDIALOG
CASE %WM_COMMAND
SELECT CASE LOWRD(CBWPARAM)
CASE %IDOK
CONTROL GET TEXT CBHNDL, %IDC_TEXT TO s
IF s = "" THEN
MSGBOX "There is no text!",,"Example"
ELSE
DIALOG END CBHNDL
MSGBOX "The text is:" & $CR & s,,"Example"
MSGBOX "Thank You for using Example",,"Example"
END IF
CASE %IDCANCEL
DIALOG END CBHNDL
END SELECT
END SELECT
END FUNCTION
I have questons about parts of this program and what they do.
WHAT DO THIS TWO LINE LET ME DO?
#DIM ALL
#REGISTER NONE
IN THE LINE
CONTROL ADD TEXTBOX, hDlg, %IDC_TEXT, "",5,15,100,14
1. hDlg is set as a long in Function PBMAIN
but it not defind in Callback FUNCTION DlgProc
can this be replaced with with a an verible?
The book has hDlg& = Handle of the dialog in wich the button will be created
So that is pre defind can't be sub with any other name so is it that
you have to declerd it "LOCAL hDlg AS LONG"
2. This line uses %IDC_TEXT in this book in the syntax has this
as unique identifier for the control it is set up to 101 in this
example. what dose this control?
3. DIALOG SHOW MODAL hDlg CALL DlgProc
I think this is call function DlgProc that is defind as a CALLBACK
and pass hDlg to that function. am I right?
4. In every program I see there is two Functions. I understand
PBMAIN wich is like main function in c++. but the CALLBACK FUNCTION
Dose it have to be a CALLBACK FUNCTION? It seems to me that
CALLBACK is a type of FUNCTION what is the this meen?
5. what do this case do and what dose two verbal have stored
in them?
CASE %WM_INITDIALOG
CASE %WM_COMMAND
SELECT CASE LOWRD(CBWPARAM)
6. in the line CONTROL GET TEXT CBHNDL, %IDC_TEXT TO s
what dose CBHNDL do? Is it some type of veribale it use elsewhere in the
7. what DIALOG END CBHNDL DO?
Sorry so long with the questons. I just like to usdersand every part of
a program so I can use part in other programs thanks for all your
help
Joe
------------------
Comment