|
can u please give me exact code if I use class wizard /DDX_check?
I tried to declare a variable called m_Alreadyset to my check button of type BOOL and set it to true in OninitDialog, but it didn't work.
|
|
|
|
|
Hi,
Setting the BOOL variable to TRUE will work only before! a call to DoDataEcxhange.
So you must set your variable to TRUE before the line CDialog::OnInitialUpdate();
or call UpdateData(false); at the end of your OnInitialUpdate-Routine.
You may also consider doing the assignment in your dialog's constructor.
Regards
G. Steudtel
|
|
|
|
|
You'll need a member variable mapped to each of the checkboxes. Then in OnInitDialog() , simply call the SetCheck() method of each member variable.
m_checkbox1.SetCheck(BST_CHECKED);
m_checkbox2.SetCheck(BST_UNCHECKED);
m_checkbox3.SetCheck(BST_CHECKED);
...
|
|
|
|
|
Some possibilities have already been given to you.
If you use classwizard, you can assign a member variable of type BOOL to a check box.
Doing this will fill in all the right code for you. As I remember (I don't touch CW
with a barge pole) you can even assign an initial value of 1 (TRUE) to it. If not,
all you have to do is find the line in the constructor which initialises the check
variable and change it to say = 1; or = TRUE; depending on taste.
If you want to do it the hard way, then the following code will help. Is assume you
have a check box of value IDC_CHECK1, and you are making a dialog class called CMyDlg.
In the header:
class CMyDlg : public CDialog
{
public:
CMyDlg (....);
....
BOOL m_bCheckValue;
....
protected:
void DoDataExchange (CDataExchange *pDX);
BOOL OnInitDialog ();
....
};
In the implementation file (eg. mydlg.cpp)
CMyDlg (...) : CDialog (....)
{
....
m_bCheckValue = TRUE;
....
}
BOOL CMyDlg::OnInitDialog ()
{
....
BOOL bReturn = CDialog::OnInitDialog ();
....
return bReturn;
}
void CMyDlg::DoDataExchange (CDataExchange *pDX)
{
CDialog::DoDataExchange (pDX);
....
DDX_Check (pDX, IDC_CHECK1, m_bCheckValue);
....
}
I put in the OnInitDialog just to remind you you need to call the base member to ensure DoDataExchange
gets called.
By putting the DDX_Check in, rather than just checking the box in OnInitDialog, we make sure that
the value is retrieved when you press OK, so you can find out whether the user cleared the check box
or not.
Iain.
|
|
|
|
|
Make sure the member variable for the checkbox is a control variable, not value...then you can use SetCheck()
|
|
|
|
|
In C++ if I provide the function and declaration at once is it automatically inline ?
|
|
|
|
|
If it is a member function, yes. For global functions you have to add the inline keyword.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
It's not guaranteed to be inline. It depends on the compiler.
|
|
|
|
|
The MSDN doc's [^] give a list of cases where the compiler can't inline, even if you specify forceinline.
The two of note are :
- default debug builds
- virtual methods
In either case the compiler will generate a normal function call.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hi!
I've created an SDI application with MFC. I want to add a splash screen during the loading of my program, to hide the main frame while loading and show it when the application has finished starting.
In my App class InitInstance function, I've deleted the two following lines:
<br />
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);<br />
m_pMainWnd->UpdateWindow();<br />
But my main frame is still visible. How to hide it while my application is starting?
Thks in advance!
Appstmd
http://www.appstmd.com
|
|
|
|
|
Check Mike Dunn's C++ FAQ[^] question 7.6, maybe it is applicable to your case.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
you could call your splash screen before the main frame is displaed
you could place this at the start OnNewDocument() function
si
|
|
|
|
|
|
Hi guys
There is a limit in the number of controls in a dialog?
There is a way to pass this number?
I was making a copy apste until the paste had less controls than the copy, then I thought that it was a limit
Best regards
Dr.pi
|
|
|
|
|
What's the point ?
~RaGE();
|
|
|
|
|
Practical answer: No, there is no limit.
Real answer: There are limits, but they're BIG ones.
A dialog box is just a window. Controls on the box are just child windows. So the limit is the
upper limit on HWNDs imposed by windows. As I remember, Win95 had a limit of 8 or 16 thousand.
Windows NT (which 2000 and XP are, despite the names) are only limited by memory. So you can have
a few million if you like.
There are earlier practical limitations though...
1) You have to be able to see them. 1 pixel x 1 pixel controls help noone. So you are generally limited
to several hundred by the screen.
2) You have to able to design it. The resource editor may well have limitations. You could use a
text editor instead, but do you have that much patience?
3) You have to be able to identify most of the controls. Window ID numbers are not infinite...
(GetDlgCtrl (UINT id)...)
The mind boggles as to WHY you care about the upper limit. Usability will kill your design
long before windows does.
Iain.
|
|
|
|
|
Hi Iain
Then maybe the limitation is more in the resource editor than in the Visual C++?
Best Regards
Dr.Pi
|
|
|
|
|
Last I knew, this limit was 255 (or 256). There is no limit when creating the controls dynamically, however. If you've the need for that many, it's better to consider a tabbed-dialog.
|
|
|
|
|
I am opening a document with a password, and attempting to save it without a password. I keep getting a type mismatch on the vtFileFmt parameter in the SaveAs function. The documentation that I have found says that the format can be one of these:
typedef enum {
wdFormatDocument = 0,
wdFormatTemplate = 1,
wdFormatText = 2,
wdFormatTextLineBreaks = 3,
wdFormatDOSText = 4,
wdFormatDOSTextLineBreaks = 5,
wdFormatRTF = 6,
wdFormatUnicodeText = 7,
wdFormatEncodedText = 7,
wdFormatHTML = 8
} WdSaveFormat;
so I'm setting the second parameter to 0. So why doesn't this work!?
_variant_t vtFileToOpen(lpszPath);
_variant_t vtTrue(VARIANT_TRUE);
_variant_t vtFalse(VARIANT_FALSE);
_variant_t vtPwd("MYPASS");
<br> <br>
Word::_DocumentPtr doc = app->Documents->Open(&vtFileToOpen, &vtTrue,
&vtFalse, &vtTrue, &vtPwd);
<br> <br>
doc->put_Password(_bstr_t(""));
_variant_t vtPwdNew("");
<code>_variant_t vtFileFmt(0);</code>
<br> <br>
if (SUCCEEDED(doc->SaveAs(&vtFileToOpen, <code>&vtFileFmt</code>)))
{
doc->put_Saved(VARIANT_TRUE);
doc->Close();
}
Also, why can't I just use put_Password(_bstr_t("")) then SaveAs with just the file name? It asks for a password the next time I open it. This works when I use SaveAs to set a password elsewhere in the app.
Sometimes I'd like to strangle whoever made OLE. Oh, and don't forget the guy who makes the documentation for this stuff. He's gonna get it too.
Jason Henderson I bleed orange.
|
|
|
|
|
My Word Automation looks a tad different than yours:
CString strFileName;
_Application app;
Documents docs;
_Document doc;
COleVariant vtOptional((long) DISP_E_PARAMNOTFOUND, VT_ERROR),
vtFalse((short) FALSE),
vtTrue((short) TRUE),
vtDoc((short) 0),
vtText((short) 2),
vtRtf((short) 6),
vtHtml((short) 8);
if (app.CreateDispatch("Word.Application") == TRUE)
{
strFileName = "SomeFile.doc";
docs = app.GetDocuments();
doc = docs.Open(COleVariant(strFileName), vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional);
strFileName.Replace(".doc", ".doc1");
doc.SaveAs(COleVariant(strFileName),
vtDoc,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional);
docs.Close(vtFalse, vtOptional, vtOptional);
app.Quit(vtOptional, vtOptional, vtOptional);
}
|
|
|
|
|
I'm opening a word document in a SDI container. It looks better than the embedded word examples I've found, but the only way to open the document into the container is by using OleCreate or OleCreateFromFile (that I have found anyway). Using these functions to open a document with a password really screws things up. Another copy of word opens up.
I'll try your vtOptional method.
Thanks
Jason Henderson I bleed orange.
|
|
|
|
|
hi there
sorry for this newbie question
is it possible to create a cdialog derieved class without using the resource editor?
|
|
|
|
|
I don't see why not.
Just create a new .h file as follows
class CMyDlg : public CDialog
{
};
and put the functionality in the corresponding .cpp file.
Maybe I did not get your question.
-Melwyn
|
|
|
|