Wednesday, 1 February 2017

change caption, string to a number of a double variable

string representation of a specified integer value

 SetDlgItemInt function

Sets the text of a control in a dialog box to the string representation of a specified integer value.

Syntax

BOOL WINAPI SetDlgItemInt(
  _In_ HWND hDlg,
  _In_ int  nIDDlgItem,
  _In_ UINT uValue,
  _In_ BOOL bSigned
);

Parameters

hDlg [in]
Type: HWND
A handle to the dialog box that contains the control.
nIDDlgItem [in]
Type: int
The control to be changed.
uValue [in]
Type: UINT
The integer value used to generate the item text.
bSigned [in]
Type: BOOL
Indicates whether the uValue parameter is signed or unsigned. If this parameter is TRUE, uValue is signed. If this parameter is TRUE and uValue is less than zero, a minus sign is placed before the first digit in the string. If this parameter is FALSE, uValue is unsigned.

Return value

Type: BOOL
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

To set the new text, this function sends a WM_SETTEXT message to the specified control.

Requirements

Minimum supported clientWindows 2000 Professional [desktop apps only]
Minimum supported serverWindows 2000 Server [desktop apps only]
Header
Winuser.h (include Windows.h)
Library
User32.lib
DLL
User32.dll


I want to change IDC_EDIT1, caption to a number of a double variable.
I used "_itoa" for normal integers, but how am i suppose to throw double value in it? 


Example of what i was using

Code:
SetDlgItemText(hWnd, IDC_EDIT1, _itoa((Value), buf, 10));

answer:

sprintf, swprintf (CRT)  to write the data to the string or  SetDlgItemInt

lol, something tells me you're trying to set the EXP value!
Nuh Uh. Retrieving. Hes trying to convert # to $ so yea.



You could extract of the decimal places from the double, multiply it by (10 ^ number of decimal places), strcat() it to the whole number part of the decimal, then set that string with SetDlgItemText.



See also

Reference
GetDlgItemInt
SetDlgItemText
WM_SETTEXT
Conceptual
Dialog Boxes

No comments:

Post a Comment

Note: only a member of this blog may post a comment.


Get paid to share your links!