|
if i drag a 'Rich Edit 2.0 Control' onto any of my CDialog based forms and then call DoModal() the dialog never appears.. if i take the rich edit out and call DoModal() the dialog pops up fine..
i've traced through the code and the constructor is called both ways, but the OnInitDialog() is never called if a Rich Edit 2.0 Control is in the dialog.. ive tried it on 2 existing dialogs i have and it does the same thing both ways..
has anyone tried to use this rich edit control under .net? i've never used one before, but all im doing is draging it onto the dialog.. get rid of it and it the dialog works..
im really confused, i've had enough of this junk for this week..
-dz
-edit-
p.s. im trying to write a dialog that takes a string (with multiple lines using '\n') and display it in a CEdit, or rich text control so that i can display some text to the screen.. and then have a print button which prints the text.. my problem is that when i set the CEdit to the string i get little boxes where the carriage returns should be.. so i thought i would try the rich edit control.. now that i cant get that to work im trying the cedit again, but i dont see a command to make it go to the next line.. any other suggestions?
p.p.s. poping up notepad would be fine too, but the commands to start a new process take about 10 parameters.
|
|
|
|
|
dazinith wrote:
if i drag a 'Rich Edit 2.0 Control' onto any of my CDialog based forms and then call DoModal() the dialog never appears.. if i take the rich edit out and call DoModal() the dialog pops up fine..
Try calling AfxInitRichEdit() in your App's InitInstance() function. If you take a look at your output window (when running under the debugger), and see a "Dialog creation failed" or similar message, the above should solve your problem.
Peace!
-=- James.
"Some People Know How To Drive, Others Just Know How To Operate A Car."
(Try Check Favorites Sometime!)
|
|
|
|
|
Check the KB article Q166132. Or just call AfxInitRichEdit before DoModal.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
You need to use '\r\n' instead of '\n' for strings passed to CEdit.
|
|
|
|
|
thanks a bunch have a good weekend!
-dz
|
|
|
|
|
How do I get DAO to print currency codes in an Excel spreadsheet cells?
I created a spreadsheet using the CDaoTableDef object and then the one holding the account balances is created as:
TableDef.CreateField("Balance",dbCurrency,dbFixedField);
We have a mix of Canada and US Dollars. How do I get a cell to hold CAD and USD before the actual balance?
thanks
ashish
|
|
|
|
|
Let me just post my code...
here the questions.
1)what IsAnyItemChecked will return by just looking at the code??
2)why running under 2000 return true and false under XP?
3) does the function need to change?if it has to change, where would it be?
oh... let me explaine what this two functions do
I have file tree control. so my tree contains folders and files name.
There are checkbox for each folder and file name. the following IsAnyItemChecked () call recursive function IsAnyItemChecked(...) to go through the whole tree and see any item (file in this case) is checked. if checked item found, check it's parent.
then return true for checked item found. if not the function will return false. that's it...
<br />
BOOL CSMPprojectDlg::IsAnyItemChecked()<br />
{<br />
HTREEITEM hItem = m_TreeCtrl.GetRootItem();<br />
<br />
int result = IsAnyItemChecked(hItem,hItem);<br />
return result;<br />
}<br />
<br />
BOOL CSMPprojectDlg::IsAnyItemChecked(HTREEITEM hItem, HTREEITEM &ParentItem)<br />
{ <br />
<br />
BOOL CheckItemFound = FALSE;
while(hItem!=NULL)<br />
{ <br />
FileInfo *fileinfo = (FileInfo*)m_TreeCtrl.GetItemData(hItem);<br />
<br />
if(m_TreeCtrl.ItemHasChildren(hItem) || fileinfo->status == FOLDER)<br />
{<br />
IsAnyItemChecked(m_TreeCtrl.GetChildItem(hItem),hItem); <br />
}<br />
if(m_TreeCtrl.GetCheck(hItem))<br />
{<br />
CheckItemFound = TRUE ;
<br />
} <br />
hItem=m_TreeCtrl.GetNextSiblingItem(hItem);<br />
<br />
}
<br />
if(CheckItemFound == TRUE && m_TreeCtrl.ItemHasChildren(hItem))<br />
{<br />
m_TreeCtrl.SetCheck(ParentItem,TRUE); <br />
}<br />
<br />
return CheckItemFound; <br />
}<br />
|
|
|
|
|
int result = IsAnyItemChecked(hItem,hItem); prolly has nothing to do with the problem, but you are setting an int to a bool result
return result; then your returning the int as a bool..
thats the only obvious thing i see.
-dz
|
|
|
|
|
hmmm.. not really .. that's ok now.. i recode my function for xp and it is running under 2000 without error. but i'm still curious why.
|
|
|
|
|
No? Try to use one.
soptest
|
|
|
|
|
What's debugger? Can I use it with Visual Basic?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Are you from Moon or Mars?
soptest
|
|
|
|
|
soptest wrote:
Are you from Moon or Mars?
I'm from Mercury. And you?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
i debug it. that's how i found out the function need to recode for xp.
after changing my code, it return true for both xp and 2000.
but i just don't understand why on 2000, the function return true but false on xp
|
|
|
|
|
Hi everyone,
can anybody here help me on how to solve my problem? I'm new to c++, how can I extact a string on a string? Example:
char *str1;
str1 = "The Quick Brown Fox Jumps Over The Lazy Dog";
How can I extract the "Brown" string from str1??? and assign it into a new variable like str2 perhaps. In VB you'll just use the MID(sting,start,len) function... is there a MID like function in C or C++??
I will really appreciate any idea that you may give.
Thanks/Regards
Sidney
Thanks/Regards
Sidney
|
|
|
|
|
Are you using MFC?
If so, you can use CString function Mid, for instance:
<br />
CString str1;<br />
str1 = "The Quick Brown Fox Jumps Over The Lazy Dog";<br />
<br />
CString str2 = str1.Mid(10,5);
I love CString. If you are using stl, there are similar functions there I think, but I don't know stl well enough. Now if you are not using MFC or stl, you can do it in a loop.
<br />
char str2[6];
for(int i = 0; i < 5; i++)<br />
str2[i] = str1[10 + i];<br />
<br />
str2[5] = '\0';
I'm sure there are other ways, too.
No generalization is 100% true.
Not even this one.
|
|
|
|
|
There is a standard C/C++ function called strstr(...) that will work for char strings. Also see the MSDN article String Manipulation for a complete list of functions.
Keep Hacking...
Jonathan Craig
www.mcw-tech.com
|
|
|
|
|
Yes, but strstr will search for a substring within a string. I think what was needed was to grab a specific chunk (e.g., start at the 5th char, and get 4 more chars), which is a little different.
No generalization is 100% true.
Not even this one.
|
|
|
|
|
Yes strstr is fine... but I need to extract with offsets, I need to especify the starting point and the length. like MID in VB. But again I cant use CString co'z I'm doing my progrtam in STL, is it possible to use CString in STL programs??
Thanks/Regards
Sidney
|
|
|
|
|
No-one does anything 'in' STL. The standard template library is part of standard C++ and is available to ALL C++ programs. The std::string class exposes iterators and is therefore considered by some to be a part of STL. I guess it is a specialisation - a container that holds characters.
CString is part of MFC, and can be used in MFC programs. Many classes exist online that emulate CString's functionality for non-MFC programs.
std::string has a substr method which takes and returns exactly what you want
std::string s("Gargle Mouse");
MessageBox(0, s.substr(5, 5).c_str(), "", 0);
should ( I am doing this untested ) bring up a dialog that said 'le Mo'.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
I have an edit box that I want to display a number in. I have a member variable (m_var1) assigned to that edit box of type int. So to display a number in that edit box, it only requres a simple assignment:
m_var1 = 36;
But I want the display to be in hex ( e.g. "0x%04x" ).
Obviously I can instead use a member variable of type CString and format the numeric value the way I want.
BUT: is there a _better_ way?
Ron
|
|
|
|
|
BlackDogEngineering wrote:
BUT: is there a _better_ way?
I think you have no choice but to format the number as a string and display that. Why not link a CString to the edit control?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
The only improvement is to use "%#04x" to automagically add the 0x prefix.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Can anybody tell me why I am getting this error for the following line:
graphics = new Graphics(hdcPrint);
For your information, this is my function:
// this function is for OTCDialog: OK button
// It uses GDI to send image to a printer
void OTRDialog::OnPrintFrom()
{
DWORD size;
HDC hdcPrint;
DOCINFO docInfo;
ZeroMemory(&docInfo, sizeof(DOCINFO));
docInfo.cbSize = sizeof(DOCINFO);
docInfo.lpszDocName = "GdiplusPrint";
// Create a PRINTDLG structure, and initialize the appropriate fields.
PRINTDLG printDlg;
ZeroMemory(&printDlg, sizeof(PRINTDLG));
printDlg.lStructSize = sizeof(PRINTDLG);
printDlg.Flags = PD_RETURNDC;
// Display a print dialog box.
if(!PrintDlg(&printDlg))
{
printf("Failure\n");
}
else
{
// Now that PrintDlg has returned, a device context handle
// for the chosen printer is in printDlg->hDC.
StartDoc(hdcPrint, &docInfo);
Graphics* graphics;
StartPage(hdcPrint);
graphics = new Graphics(hdcPrint);
Image image(L"My_report.bmp");
graphics.DrawImage(&image, 5, 0, 360, 410);
// Create a string.
WCHAR string[256];
wcscpy(string, L"Sample Text");
// Initialize arguments.
Font myFont(L"Arial", 6);
PointF origin(20.0f, 5.0f);
SolidBrush blackBrush(Color(255, 0, 0, 0));
// Draw string.
graphics.DrawString(string, wcslen(string), &myFont, origin, &blackBrush);
delete graphics;
EndPage(hdcPrint);
EndDoc(hdcPrint);
DeleteDC(hdcPrint);
}
if(printDlg.hDevMode)
GlobalFree(printDlg.hDevMode);
if(printDlg.hDevNames)
GlobalFree(printDlg.hDevNames);
if(printDlg.hDC)
DeleteDC(printDlg.hDC);
}
|
|
|
|
|
How many parameters does the constructor for Graphics take? Sounds like your giving it less than the number required.
|
|
|
|