Sign in to follow this  
ostamo1

win 32 Resources and programming

Recommended Posts

i went and created a new dialog in viscpp6 then i started to add edit box controls to it is there a way to update these 3 edit boxed with random nubers i have tried but i am not sure i am passing all the parameters correctly i keep getting this error //////////////////////////////////////////////// error C2664: 'SetWindowTextA' : cannot convert parameter 1 from 'const int' to 'struct HWND__ *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast ////////////////////////////////////////////////
SetDlgItemInt(IDD_MAIN,IDC_EDIT1,1,true);
	SetWindowText(IDC_EDIT1,"1");
[Edited by - ostamo1 on September 21, 2004 11:38:30 AM]

Share this post


Link to post
Share on other sites
Use SetDlgItemText() or SetDlgItemInt()

SetDlgItemText(hwndDialog, IDC_EDIT1, "1");
SetDlgItemInt(hwndDialog, IDC_EDIT1, rand(), FALSE);

Also you should be passing an HWND as the 1st param of SetDlgItemInt, it looks like you just have a resource identifier.

Share this post


Link to post
Share on other sites
thanks man that helped alot

your rating++

/////////////////////////////////////////////////////////

now i need extra help on these edit boxes
my resource file
i only want edit box 1-6 to change but my loop changes them all
even the button caption
have i missed something???

[code]
///////////////////////////////////////////////////
#define IDC_EDIT1 1000
#define IDC_EDIT2 1001
#define IDC_EDIT3 1002
#define IDC_EDIT4 1003
#define IDC_EDIT5 1004
#define IDC_EDIT6 1005
///////////////////////////////////////////////////
#define IDC_STRMOD 1007
#define IDC_DEXMOD 1008
#define IDC_CONMOD 1009
#define IDC_INTMOD 1010
#define IDC_WISMOD 1011
#define IDC_CHARMOD 1012
///////////////////////////////////////////////////
#define IDC_ROLL 1006
[/code}


my loop to edit the resources

[code]
case IDC_ROLL:
{
// SetDlgItemText(hWndDlg, IDC_EDIT1, "1");
int IDNUM =IDC_EDIT1;
// 1007;
int IDNUMMAX =IDC_EDIT6;
// 1012;

int randnum;
for (int x = 0; x < IDNUMMAX; x++)
{
randnum = 3* (rand()%6 + 1);
SetDlgItemInt(hWndDlg, IDNUM, randnum, FALSE);
++IDNUM;
}
}
break;
[/code}

[Edited by - ostamo1 on September 21, 2004 11:43:03 AM]

Share this post


Link to post
Share on other sites
You've got too many unnecessary variables there changing all sorts of ways, you've just confused yourself. Try:


for (int x = IDC_EDIT1; x <= IDC_EDIT6; x++)
{
randnum = 3* (rand()%6 + 1);
SetDlgItemInt(hWndDlg, x, randnum, FALSE);
}



Also, don't use ALL CAPS for variable names, that is usually reserved for #defines and sometimes constants/enums.

Share this post


Link to post
Share on other sites
sorry the caps were just for testing

another question
how do i get the value from the edit box and put it in a static
box
but before i put it in that box if it is higher than 6 i want the box to say 2 else it will say one
and i need this to happen for 6 static boxes
i tried this but it onley return 1 not what was in the edit box
[code]
int randnum;
int *rndnum = &randnum;
for (int x = IDC_EDIT1; x <= IDC_EDIT6; x++)
{
randnum = 3* (rand()%6 + 1);
SetDlgItemInt(hWndDlg, x, randnum, FALSE);
}


GetDlgItemInt(hWndDlg, IDC_EDIT1, rndnum, FALSE);
// GetDlgItemInt(
SetDlgItemInt(hWndDlg, IDC_STRMOD , *rndnum, FALSE);

[\code]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this