Click here to Skip to main content
15,888,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: create window groups Pin
shaosean29-Oct-09 8:39
shaosean29-Oct-09 8:39 
AnswerRe: create window groups Pin
Maximilien29-Oct-09 4:32
Maximilien29-Oct-09 4:32 
QuestionProblem in SetFont of GroupBox Caption in PropertyPages? Pin
Le@rner29-Oct-09 2:40
Le@rner29-Oct-09 2:40 
AnswerRe: Problem in SetFont of GroupBox Caption in PropertyPages? Pin
David Crow29-Oct-09 3:08
David Crow29-Oct-09 3:08 
QuestionStatic Control in Combo Pin
kumar sanghvi29-Oct-09 1:42
kumar sanghvi29-Oct-09 1:42 
AnswerRe: Static Control in Combo Pin
Covean29-Oct-09 2:07
Covean29-Oct-09 2:07 
Questionsaving the external input number to a variable Pin
raviteja202029-Oct-09 1:10
raviteja202029-Oct-09 1:10 
AnswerRe: saving the external input number to a variable Pin
enhzflep29-Oct-09 1:59
enhzflep29-Oct-09 1:59 
Your approach does seem to be the correct one. I guess (as always) the devil's in the detail..

Don't know if you're using mfc or just plain c. Here's some code that works without mfc.

STEP 1: Create the main program window and the necessary controls.
#define IDC_EDIT 1001
HFONT hfont0 = CreateFont(-11, 0, 0, 0, 400, FALSE, FALSE, FALSE, 1, 400, 0, 0, 0, ("Ms Shell Dlg 2"));
hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_APPWINDOW, szClassName, "Dialog", WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU, 0, 0, 285, 78, 0, 0, hThisInstance, 0);
HWND hCtrl0_0 = CreateWindowEx(0, WC_BUTTON, ("OK"), WS_VISIBLE | WS_CHILD | WS_TABSTOP | 0x00000001, 234, 15, 35, 23, hwnd, (HMENU)IDOK, hThisInstance, 0);
HWND hCtrl0_1 = CreateWindowEx(0, WC_EDIT, 0, WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_BORDER | ES_AUTOHSCROLL, 162, 15, 66, 23, hwnd, (HMENU)IDC_EDIT, hThisInstance, 0);
HWND hCtrl0_2 = CreateWindowEx(0, WC_STATIC, ("Enter a +ive Int:"), WS_VISIBLE | WS_CHILD | WS_GROUP | SS_LEFT, 63, 24, 84, 13, hwnd, (HMENU)-1, hThisInstance, 0);
SendMessage(hCtrl0_0, WM_SETFONT, (WPARAM)hfont0, FALSE);
SendMessage(hCtrl0_1, WM_SETFONT, (WPARAM)hfont0, FALSE);
SendMessage(hCtrl0_2, WM_SETFONT, (WPARAM)hfont0, FALSE);





STEP 2: Handle the WM_COMMAND message in our message handling function
(and in this example, show the number entered as well as 2x the number entered)
case WM_COMMAND:
    switch(LOWORD(wParam))
    {
            case IDOK:
                tmp = GetDlgItemInt(hwnd, IDC_EDIT, &didSucceed, false);  // parent, control id, pointer to success bool, is signed?
                sprintf(successStr, "%d\n2 * num = %d", tmp, tmp*2);
                if (didSucceed)
                    MessageBox(NULL, successStr, "Number entered:", MB_OK);
                else
                    MessageBox(NULL, "Invalid number!", "Error", MB_OK);
    }
    break;


modified on Thursday, October 29, 2009 10:37 PM

QuestionRe: saving the external input number to a variable Pin
David Crow29-Oct-09 2:39
David Crow29-Oct-09 2:39 
AnswerRe: saving the external input number to a variable Pin
Iain Clarke, Warrior Programmer29-Oct-09 2:56
Iain Clarke, Warrior Programmer29-Oct-09 2:56 
QuestionCComboBox in CHeaderCtrl of CListCtrl Pin
Sheebuk29-Oct-09 0:03
Sheebuk29-Oct-09 0:03 
AnswerRe: CComboBox in CHeaderCtrl of CListCtrl Pin
Iain Clarke, Warrior Programmer29-Oct-09 3:07
Iain Clarke, Warrior Programmer29-Oct-09 3:07 
GeneralRe: CComboBox in CHeaderCtrl of CListCtrl Pin
Sheebuk29-Oct-09 5:50
Sheebuk29-Oct-09 5:50 
QuestionMaking a DNS (domain name system) resolver with c++ [modified] Pin
marti8628-Oct-09 23:59
marti8628-Oct-09 23:59 
AnswerRe: Making a DNS (domain name system) resolver with c++ Pin
David Crow29-Oct-09 2:40
David Crow29-Oct-09 2:40 
QuestionExecuting a process a startup of System?(Vista & Windows 2008) [modified] Pin
Kushagra Tiwari28-Oct-09 23:40
Kushagra Tiwari28-Oct-09 23:40 
AnswerRe: Executing a process a startup of System?(Vista & Windows 2008) Pin
Iain Clarke, Warrior Programmer29-Oct-09 0:19
Iain Clarke, Warrior Programmer29-Oct-09 0:19 
AnswerRe: Executing a process a startup of System?(Vista & Windows 2008) Pin
Kushagra Tiwari29-Oct-09 0:42
Kushagra Tiwari29-Oct-09 0:42 
GeneralRe: Executing a process a startup of System?(Vista & Windows 2008) Pin
dxlee29-Oct-09 3:48
dxlee29-Oct-09 3:48 
GeneralRe: Executing a process a startup of System?(Vista & Windows 2008) Pin
Kushagra Tiwari29-Oct-09 4:00
Kushagra Tiwari29-Oct-09 4:00 
GeneralRe: Executing a process a startup of System?(Vista & Windows 2008) Pin
dxlee29-Oct-09 4:02
dxlee29-Oct-09 4:02 
GeneralRe: Executing a process a startup of System?(Vista & Windows 2008) Pin
Kushagra Tiwari29-Oct-09 4:04
Kushagra Tiwari29-Oct-09 4:04 
QuestionHow to check if any specific folder is empty Pin
sunny_vc28-Oct-09 23:07
sunny_vc28-Oct-09 23:07 
AnswerRe: How to check if any specific folder is empty Pin
Richard MacCutchan28-Oct-09 23:21
mveRichard MacCutchan28-Oct-09 23:21 
AnswerRe: How to check if any specific folder is empty Pin
Randor 28-Oct-09 23:23
professional Randor 28-Oct-09 23:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.