I am using the below code to popup the authentication dialog. I want to hard-code the password in my code and make it a read-only text box. What should I do?
IDD_LOGIN_AUTH_DIALOG DIALOG DISCARDABLE 0, 0, 148, 82
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Authentication"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Host:",IDC_STATIC_HOST,7,8,36,10,SS_CENTERIMAGE |
NOT WS_GROUP
EDITTEXT IDC_VNCHOST,46,7,95,12,ES_AUTOHSCROLL | ES_READONLY |
NOT WS_TABSTOP
CONTROL 108,IDC_STATIC_LOGO,"Static",SS_BITMAP,7,23,32,30
RTEXT "User name:",IDC_STATIC_LOGIN,41,25,39,10,SS_CENTERIMAGE
EDITTEXT IDC_LOGIN_EDIT,84,24,57,12,ES_AUTOHSCROLL
RTEXT "Password:",IDC_STATIC_PASSWD,41,42,39,10,SS_CENTERIMAGE
EDITTEXT IDC_PASSWD_EDIT,84,41,57,12,ES_PASSWORD | ES_READONLY |
NOT WS_TABSTOP
DEFPUSHBUTTON "&OK",IDOK,20,61,50,14
PUSHBUTTON "&Cancel",IDCANCEL,77,61,50,14
END
You get full control over all fields if you use the CONTROL keyword rather than the EDITTEXT keyword, use
CONTROL "mypassword", IDC_PASSWD_EDIT, "Edit",
ES_LEFT | WS_BORDER | ES_PASSWORD | ES_READONLY,
84,41,57,12
instead of
EDITTEXT IDC_PASSWD_EDIT,84,41,57,12,ES_PASSWORD | ES_READONLY | NOT WS_TABSTOP
From memory:
HWND hwnd = ...//handle to the dialog
::SetDlgItemText(hwnd, IDC_STATIC_PASSWD, "YourText");
::EnableWindow(::GetDlgItem(hwnd, IDC_STATIC_PASSWD), FALSE);
Related
I have searched in toolbox and many post but don't know where to find this type of control to use on MFC:
Does such a control exist in MFC?
The control is known as a "Spin Control" in the Visual Studio Resource editor and they are normally associated with a "Buddy" edit control. You can set this in the "Behaviour" group of its "Properties" window – with "Auto Buddy" set to "True", it will associate with the 'nearest' edit control (actually, the previous control in the Z-order). You will probably also want to have "Set Buddy Integer" set to "True".
There are numerous routines associated with such controls (such as those to set/get the range and position), and the behaviour is encapsulated in the CSpinButtonCtrl class, for which there is a good overview here.
If you prefer to manually edit/create your resource scripts, then you'll need a control of the msctls_updown32 class, which should be added immediately following the buddy edit window, as in the following code excerpt:
IDP_OPTMD DIALOGEX 0, 0, 262, 180
STYLE WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CAPTION
CAPTION L"Dilation/Skeletonisation"
FONT 10, P_GUIFONT
{
GROUPBOX L"Pixel Dilation Options", IDC_DILPG, 10, 6, 247, 99, BS_GROUPBOX | SS_NOTIFY
AUTOCHECKBOX L"Enable advanced options dialogue box?", IDC_DILEO, 17, 17, 160, 11, BS_AUTOCHECKBOX
LTEXT L"Cycles =", IDC_DCYCS|0x8000, 190, 18, 30, 11, SS_NOTIFY
EDITTEXT IDC_DCYCS, 221, 17, 28, 12, ES_CENTER | ES_NUMBER, WS_EX_CLIENTEDGE
CONTROL 1, IDC_DCYUD, L"msctls_updown32", UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |UDS_ARROWKEYS
| UDS_NOTHOUSANDS, 241, 17, 12, 10
//...
I'm working on pagination for my C++ app - I want to show currentPage / allPages on CTEXT and I'm having hard time making the printing functionality work.
This is how's widget configured in .rc file (I don't mind switching from CTEXT to any other
IDD_PIC_PLAYER_DIALOG DIALOG 0, 0, 400, 247
STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE
EXSTYLE WS_EX_APPWINDOW | 0x80000000L
FONT 8, "MS Shell Dlg"
BEGIN
CTEXT "Static",IDC_PG,211,183,65,62
END
Widget has .bmp background I'm intending to be writing on.
IDB_PG BITMAP "res\\pg.bmp"
This is how my code looks like :
TCHAR szPageText[64] = TEXT("");
wsprintf(szPageText, TEXT("%d of %d"), iCurSelPage, m_iPageCount);
this->SetDlgItemText(IDC_PG, szPageText);
Code compiles, but does not doing what it's supposed to do - print those 2 integers.
If anybody knows what piece of puzzle am I missing here - I'd be grateful.
Thanks for your insight.
The edges of my tab control (SysTabControl32) are not fully repainted after restoring dialog box from minimized state.
Example:
The control is defined in the resource file (EDIT all occurences of IDD_VJOYCONF):
IDD_VJOYCONF DIALOGEX 0, 0, 245, 282
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "vJoyConf - Configure vJoy Devices"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "Reset All",IDC_RSTALL,98,261,50,14
CONTROL "",IDC_DEVTABS,"SysTabControl32",TCS_MULTILINE | TCS_TOOLTIPS,7,7,231,247
END
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_VJOYCONF, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 238
TOPMARGIN, 7
BOTTOMMARGIN, 275
END
END
#endif // APSTUDIO_INVOKED
Developing with VS2013 on Windows 8.
The problem was solved by lifting the margin of the dialog box internal to the tab control.
The more interesting thing is how I found the problem.
I used Sysinternals Process Explorer. It has a 'Find Window's Process' button:
[EDIT:]
I hovered over the entire dialog box, highlighting its various elements until I've highlighted the culprit element:
You can clearly see that it's bottom is clipped exactly where the problem is. This is the dialog box that is embedded in the tab control.
The solution was to raise the dialog box so it won't be clipped.
As I'm (finally) learning to code Windows apps in C++ I stumbled upon this: I have a dialog box which I create with CreateDialog() and I also have a default button. However, each time I press TAB or ENTER, nothing happens, nor does the control focus change, nor does the default button activate. Here's the resource for my dialog.
IDD_MAINWIND DIALOG 0, 0, 312, 205
STYLE DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_GROUP | WS_POPUP | WS_SYSMENU
EXSTYLE WS_EX_WINDOWEDGE
CAPTION "Dialog"
FONT 8, "Tahoma"
{
PUSHBUTTON "&Send", IDC_BUTTON_SEND , 280, 168, 22, 14, BS_DEFPUSHBUTTON
LTEXT "Hello", IDC_STATIC1, 9, 9, 296, 149, SS_LEFT | SS_NOPREFIX | SS_SUNKEN, WS_EX_TRANSPARENT
EDITTEXT IDC_MESSAGE, 9, 168, 265, 13, ES_AUTOHSCROLL
PUSHBUTTON "Tools", IDC_BUTTON_TOOLS, 8, 185, 146, 14
PUSHBUTTON "Exit", IDC_BUTTON_EXIT, 163, 185, 136, 14
}
Any help is greatly appreciated. Especially now on the 3rd day of Christmas.
The solution is to add WS_TABSTOP styles to every child element of the dialog box.
For ex.:
PUSHBUTTON "&Send", IDC_BUTTON_SEND , 280, 168, 22, 14, BS_DEFPUSHBUTTON | WS_TABSTOP
Be sure that every control has WS_VISIBLE | WS_CHILD styles.
Also do not forget to add WS_EX_CONTROLPARENT style to the window and remove WS_GROUP style from the dialog window.
Moreover
Check your dialog proc
Or if you use window proc instead use the following snippet
Tabbing is provided by the dialog manager, not the Window manager. Therefore, to get tab handling, you need to call IsDialogMessage in your message loop with the hwnd of your window:
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
if (!IsDialogMessage(hwnd, &messages))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
}
Please, learn about WS_TABSTOP and WS_GROUP dialog box items attributes.
This link should be helpful for you: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644994.aspx#controls
i have edit text control with text that im loading to it ,
i want some of the text to be in color x and some in color y , how can it be done?
also can i make clickble link inside of the edittext?
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG1 DIALOG 0, 0, 369, 318
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
CAPTION "Win32 demo"
FONT 8, "Ms Shell Dlg"
{
EDITTEXT IDC_EDIT2, 8, 1, 353, 86, NOT WS_BORDER | ES_AUTOHSCROLL | ES_MULTILINE | ES_READONLY
}
You can't do that in a standard edit control. You need a rich edit control for that. Based on your previous question I do wonder if what you really need is a hyperlink which you can do with the SysLink control.