|
You're using VC5 ? Why ?
However, I'd have hoped it could do that, although C++ exceptions kind of suck if you're in any way used to .NET ones.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Why and How would that upset .NET?? My code is not NET aware, and will not ever be required to run under NET
LateNightsInNewry
|
|
|
|
|
Imagine if your company car was a Ferrari and on weekends you had to drive a scooter. The scooter is still a scooter, but you'd feel a lot worse about sitting on it if you were used to a Ferrari.
It won't matter to .NET, I meant that if you had used .NET exceptions and then tried to use C++ exceptions, you'll find yourself wishing they did more.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Get your Drift, however;
This question is not so much about a Ferari which I do not posess, but about the scooter going from A to B. You may be fortunate enough to write for a client base equiped with the latest harware. I am not so fortunate, the Software I write is supposed to run on Win98-SE. The question is still the same, Hoe do I throw exceptions by say Number under VCPP5.0
LateNightsInNewry
|
|
|
|
|
LateNightsInNewry wrote: the Software I write is supposed to run on Win98-SE
OK. Are you under the mistaken impression that this means you need to use VC5 ?
Either way, I can't comment on VC5, but I would expect in general that anything that VC6 does in this regard, VC5 should be fine. Perhaps if you posted your code ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: Perhaps if you posted your code ?
The problem with that is, The code has not been written yet. I am doing something before I write code, which is called 'Planning your Process'. The Larger plan is as follows:-
I am writing a Server Client Program, where the Server maintains a Database, which is accessed by clients by requests for either information or update. Server and Clients typically run on different machines on a local network, but communicate by structured messages sent over a WIN32 Pipe. I am now investigating the possibility of terminating a long process on the Server, by means of the User on the Client Terminal clicking on 'Cancel' on the Wait box.
The entire design of the system is 'Proprietory' and 'From the Ground up', and is purpously designed to be non-compatible with any Microsoft Database format. Iam now looking for an exception handeling mechanism which handles exceptions by GUID_EXCEPTION_ID. If something like this exists already, I'll use it. If it does Not exist I've to Invent it.
LateNightsInNewry
|
|
|
|
|
The low level OS provided SEH is primarily used as a layer to implement higher level exception constructs used in higher level languages such as C++ or the .NET languages. I'm not sure about MSVC5 but I'd be surprised to find it works very differently from MSVC6 or higher.
Steve
|
|
|
|
|
just recently got visual studio 2005 and well to put a long story short it has been driving me crazy lol. but anyways i had to switch from using soem of the old libraries to usign the new ones and it has caused nothing but trouble. in my vc 6 i had a piece of code that would put any text i passed into a ostrstrea object(which in 2005 now is ostringstream) and it was stored into a char buffer which i would pass the buffer off to the setwindowtext function of a cedit control and it would display any text in the buffer but after a few changes to allow my program to compile the text will not display and i am not quite sure why. i have the code set up to work as it did in vc 6 but i am not sure what changes were made that now causes it to fail in vc 8, if someone could help me figure out what might be wrong i would greatly appreciate it.
|
|
|
|
|
swatgodjr wrote: i passed into a ostrstrea object(which in 2005 now is ostringstream)
I suspect this means you used to use strstream.h. The standard headers you're now using in VC2005 were there in VC6, but it's taken this long for the headers that are not part of standard C++ to be removed from the Microsoft compiler.
swatgodjr wrote: but i am not sure what changes were made
All the the changes made were to make the compiler more standards compliant, in other words, if your code had been legal C++, it would not have caused any problems.
swatgodjr wrote: if someone could help me figure out what might be wrong i would greatly appreciate it.
I'm more than happy to help. Not much I can do without seeing the code
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
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 />
|
|
|
|