|
ok not a problem, i been constantly looking for ways to redo the code correctly but not much luck yet well heres the code to one part of my program:
<br />
const int TEXT_SIZE = 5000;<br />
char szbuf[TEXT_SIZE];<br />
std::ostringstream str(szbuf);<br />
<br />
void CHelpDialog::help_mes(char num[], bool cnt, char mess[])<br />
{<br />
if(cnt == true)<br />
{<br />
str << " " << num << ". " << mess << "\r" << std::endl;<br />
<br />
}<br />
if(cnt == false)<br />
{<br />
str << " " << mess << "\r" << std::endl;<br />
}<br />
}<br />
<br />
BOOL CHelpDialog::OnInitDialog()<br />
{<br />
CEdit *pHelpText;<br />
pHelpText = (CEdit *) GetDlgItem(IDC_HELPTEXT);<br />
<br />
str.seekp(0);<br />
<br />
help_mes("1", true, "Everything entered in this program is case-sensitive so if");<br />
help_mes("", false, "your program fails to load when you type in name of the plug");<br />
help_mes("", false, "in to load, check if you spelled it correctly with the right");<br />
help_mes("", false, "capitalization.\n");<br />
help_mes("2", true, "If the program you enter fails to load, make sure you have the");<br />
help_mes("", false, "required dll files needed for the program.");<br />
help_mes("3", true, "If there is any more bugs found than please contact me to let me");<br />
help_mes("", false, "know. I can be reached at swatgod@gmail.com.\n");<br />
<br />
pHelpText->SetWindowText(szbuf);<br />
memset(szbuf, 0, sizeof(szbuf));<br />
<br />
return true;<br />
}<br />
that is all the code that basically deals with the problem area, any advice is very much appreciated .
|
|
|
|
|
I'd replace it all with the following:
BOOL CHelpDialog::OnInitDialog()
{
std::ostringstream str();
str << "enter your text here, the helper function doesn't seem that useful to me";
CEdit *pHelpText;
pHelpText = (CEdit *) GetDlgItem(IDC_HELPTEXT);
pHelpText->SetWindowText(str.str().c_str());
return true;
}
Why are you putting \r AND std::endl ?
If you must have the helper fumction, I'd use a conditional operator, as in
str << " " << ((cnt) ? num : mess) << std::endl;
Although as it stands you pass two char arrays each time, and each time use only one, which seems kind of redundant.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
umm i just noticed something rather interesting. your code works perfectly and yet when i made the small change that you had made i still get no text and i think now i understand why that is. but also i have a function like that since i once had this program being used in a console app and in that version separated a lot of my most common chunks of code into a separate dll that i used in multiple programs and just have not gotten around to redoing the same process in my gui apps. and i also use /r and endl because if i don't it will not terminate and drop other pieces of text to another line with how i was doing text in my cedit boxes in my program.
|
|
|
|
|
OK, so your own code requires the \r and ignores somehow the \r\n being put in by std::endl ?
Either way, your problem is solved then ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
yes, thanks to your help it is fixed. thank you for the help.
|
|
|
|
|
no worries - just wanted to make sure we'd solved it
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I want to Copy a Bitmap from the CImageList and copy to CBitmap object, i tried this function i tool from the Codeguru, but whenever i call this function everytime it increases the Memory usage of my Program. can anyone tell me how to control this ???
void GetImageFromList(CImageList *lstImages, int nImage, CBitmap *destBitmap)
{
//First we want to create a temporary image list we can manipulate
CImageList tmpList;
tmpList.Detach();
tmpList.Create(lstImages);
//Then swap the requested image to the first spot in the list
tmpList.Copy( 0, nImage, ILCF_SWAP );
//Now we need to get som information about the image
IMAGEINFO lastImage;
tmpList.GetImageInfo(0,&lastImage);
//Heres where it gets fun
//Create a Compatible Device Context using
//the valid DC of your calling window
CDC dcMem;
dcMem.CreateCompatibleDC (GetWindowDC());
//This rect simply stored the size of the image we need
CRect rect (lastImage.rcImage);
//Using the bitmap passed in, Create a bitmap
//compatible with the window DC
//We also know that the bitmap needs to be a certain size.
destBitmap->CreateCompatibleBitmap (this->GetWindowDC(),
rect.Width (), rect.Height ());
//Select the new destination bitmap into the DC we created above
CBitmap* pBmpOld = dcMem.SelectObject (destBitmap);
//This call apparently "draws" the bitmap from the list,
//onto the new destination bitmap
tmpList.DrawIndirect (&dcMem, 0, CPoint (0, 0),
CSize (rect.Width (), rect.Height ()), CPoint (0, 0));
//cleanup by reselecting the old bitmap object into the DC
dcMem.SelectObject (pBmpOld);
}
Please help me whts wrong in this CODE ? or if u have any idea how to Copy the Single Bitmap from Image list and copy to CBitmap tell me how ??
|
|
|
|
|
Manni Singh wrote: tmpList.Detach();
I suspect this leaks the list that was already there, although it should be empty if there is one. It's at a minimum redundant.
Is destBitmap being created as a pointer ? I'm wondering if it's the leak ( from the calling code ) ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I think (not sure)I answered to like this for extract images of CImageList to a hbitmap you can use Search comment
|
|
|
|
|
I want to know when an edit box is clicked. I have found ON_EN_CHANGE is triggered only when I enter a character in the edit box. Is there any mesage triggered when I just click the edit box?
Thanks.
UPDATE: I found it. ON_EN_SETFOCUS triggers whn the edit box is clicked. Is there any drawback to using this?
-- modified at 13:03 Sunday 24th September, 2006
|
|
|
|
|
Oliver123 wrote: ON_EN_SETFOCUS
This wont get fired the next time you click on it. I mean when the focus is already there.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
moreover, WM_SETFOCUS will be sent if he navigates to his control using the Tab key...
|
|
|
|
|
Handle the WM_LBUTTONDOWN message.
Software Zen: delete this;
|
|
|
|
|
Is here any way to programmatically control(Add/Remove) the content listed in "Open With"->"Recommended Application". I believe this is recorded inside regisry, but where can I find it?
|
|
|
|
|
First you need the file extension say .xyz
HKEY_CLASSES_ROOT\.xyz
Look at the default value: xyz_auto_file
HKEY_CLASSES_ROOT\xyz_auto_file
Go into the sub-tree
HKEY_CLASSES_ROOT\xyz_auto_file\shell\open\command
I am quite sure that the file listed there is the one you are after.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Hi all:
The following is the code snippet for print the Rich Edit control, but they to no avail. MSDN says EM_FORMATRANGE EM_DISPLAYBAND should be used, but they don't seem to work, I run out of idea.
<br />
PRINTDLG printDlg;<br />
ZeroMemory(&printDlg, sizeof(printDlg));<br />
printDlg.lStructSize = sizeof(printDlg);<br />
printDlg.Flags = PD_RETURNDC;<br />
<br />
if(!PrintDlg(&printDlg))<br />
{<br />
printf("Failure\n");<br />
}<br />
else<br />
{<br />
long lLineWidth = ::MulDiv(GetDeviceCaps(PHYSICALWIDTH),1440, GetDeviceCaps(LOGPIXELSX));<br />
FORMATRANGE fmtRange;<br />
RECT rect;<br />
RECT page;<br />
int last = 0;<br />
<br />
page.left = 0;<br />
page.top = 0;<br />
page.right = ::MulDiv(GetDeviceCaps(PHYSICALWIDTH), 1440, GetDeviceCaps(LOGPIXELSX));<br />
page.bottom = ::MulDiv(GetDeviceCaps(PHYSICALHEIGHT),1440, GetDeviceCaps(LOGPIXELSY));<br />
rect = page;<br />
<br />
fmtRange.hdc = MyDC.m_hDC;<br />
fmtRange.hdcTarget = MyDC.m_hAttribDC;<br />
fmtRange.rc = rect;<br />
fmtRange.rcPage = page;<br />
<br />
::SendMessage( m_REControl50W.m_hRE, EM_FORMATRANGE, TRUE, (LPARAM)&fmtRange); <br />
::SendMessage( m_REControl50W.m_hRE, EM_SETTARGETDEVICE, (WPARAM)printDlg.hDC, lLineWidth); <br />
::SendMessage( m_REControl50W.m_hRE, EM_DISPLAYBAND, (WPARAM) NULL, (LPARAM)&rect); <br />
<br />
|
|
|
|
|
About my project, user have to choose the folder for process some job.
I only have ever use Dialog for Save and Open file but never use the Dialog that use for select folder.
Please give me some recommend for this issue.
|
|
|
|
|
Derive a class from CFileDialog and implement OnFolderChange (i think) to suit your needs
|
|
|
|
|
try
SHBrowseForFolder()
Tanvon
the brain behind ...
I Blog here
|
|
|
|
|
|
If you dont want SHBrowseForFolder you can make your control with CTreeCtrl you can see examples on codeproject about it
|
|
|
|
|
Is there a way of building an ADO Recordset from some data?
I need to return a Recordset structure from a function but the data is not available trough a database so the ideea was to load the recordset and return it. I want to do this because for some user settings my application cannot read data from a database and building my own recordset beats going trough all the code and reading settings. I can simply change the method that does the querying.
Thanks
|
|
|
|
|
GDay everyone,
I need to save received characters into a file and display them to the screen later on in C programming.
How to write a character pointed into a file in function A, and display it in a function B?
Please help. Thanks in advance
eric
|
|
|
|
|
You can do that by many ways. You can use std::fstream , or the MFC's CFile or a direct "fopen" in C. Try searching these keys.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
u can use fopen method to open a file like this
<br />
FILE* pFile = fopen("file.txt", "a");<br />
where "file.txt" is the file name and "a" is the mode (Opens for writing at the end of the file (appending))
u can learn more if u look for this function in the MSDN help
use fprintf to write to the file
<br />
fprintf(pFile, "%s\n",szString);<br />
where szString is any Character string !!
note: dont forget to close the file
<br />
fclose(pFile);<br />
|
|
|
|