Hello there..I need some help with controls in WIN APIs..Actually I just began programming in windows for an assignment and am not used to it. My problem is as follows:
I need to to display a string to a textbox when a button is ...So I used this piece of code in the "switch(Message)" :
Where IDC_... is defined in a header file and used in a resource file as follows:Code:case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_ADD: { SetDlgItemText(hwnd, IDC_TEXT, "This is a string"); }break; }
BUT the project wont compile ..Displaying the error that STYLE DS_MODALFRAME is wrong.. So I tried giving an id for my button in the following code(discarding the definition in the resource file and in the header for the controls):Code:IDD_MAIN DIALOG DISCARDABLE 0, 0, 207, 156 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Controls One" FONT 8, "MS Sans Serif" BEGIN LTEXT "Add",IDC_STATIC,7,10,14,8 EDITTEXT IDC_TEXT,25,7,120,14,ES_AUTOHSCROLL EDITTEXT IDC_NUMBER,150,7,21,14,ES_NUMBER LTEXT "times.",IDC_STATIC,177,10,23,8 LISTBOX IDC_LIST,7,25,138,106,LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "&Add",IDC_ADD,150,30,50,14 PUSHBUTTON "&Remove",IDC_REMOVE,150,47,50,14 PUSHBUTTON "&Clear",IDC_CLEAR,150,63,50,14 LTEXT "This item was added",IDC_STATIC,7,141,66,8 CTEXT "-",IDC_SHOWCOUNT,77,141,32,8 LTEXT "times",IDC_STATIC,114,141,17,8 END
Code://create a default push button CreateWindowEx(0, //more or 'extended' styles TEXT("BUTTON"), //'class' of control to create TEXT("Roll Dice"), //the control caption WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON, //control style: how it looks 500, //control position: left 250, //control position: top 100, //control width 30, //control height hwnd, //parent window handle NULL, //control's ID g_hInst, //application instance NULL);
Now the project compiles but the button dont work....CAN ANYONE PLZ HELP ME OUT??
Compiler : DEV C++
OS: WIN XP
Source code obtained from: theForger's Win32 API Tutorial & http://www.foosyerdoos.fsnet.co.uk/



LinkBack URL
About LinkBacks


