|
This sounds like you will need to make use of 2 of my printing artcles:
PrintExtension.asp[^]To get print/print preview support into your dialog
and
PrintLongText.asp[^]
which will print out a long line of text in a CString variable across multiple pages. If you can get your data into a string like this then is should do everything that you need (hopefully)
Roger Allen
Sonork 100.10016
This is a multiple choice question, choose wisely
Why did the hedgehog cross the road?
A: To show he had guts?
B: To see his flat mate?
|
|
|
|
|
Hi
Is it possible to write our own operators ( I'm not talking about operator overloading ) in C++, like what the language itself offers. For e.g. currently the switch operator does not work with strings it needs constants so if I'm able to write a operator which would be similar to switch but be able to work strings also then it would be great.
Ciao
- Nilesh
|
|
|
|
|
You cannot add keywords to the C++ language or change their behaviour excepting the mechanisms offered by operator overloading.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Well, you could probably do crafty stuff with defines, but that's not to be recommended at all
(That reminds me of a bit of microsoft code I saw ages ago that used defines to make Pascal style for loops! arrgh!)
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Macros are almost *always* evil.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I've been using a way to sorta do switch's on strings. The overall idea is to use a function that converts the string to a number. For convienence and speed I used CRC32. I also created a macro/add-in for DevStudio so that I can just highlight some text and calculate the CRC32. For instance:
switch (Crc32( x ))<br />
{<br />
case 0xde080b5a:<br />
OnLicence();<br />
break;<br />
case 0xb644dd13:<br />
Tabs.ShowPage( 1 );<br />
break;<br />
case 0xb4629e6c:<br />
Tabs.ShowPage( 2 );<br />
break;<br />
}
Personally I think it makes the code pretty readable and maintable (If you ignore how badly the html mangles the spacing). Sure it has to do a bit more work, but the code maintainence is a breeze.
Joel Lucsy
|
|
|
|
|
Uhm. You call this maintainable? CRC checksums?
--
There's a new game we like to play you see. A game with added reality. You treat me like a dog, get me down on my knees.
We call it master and servant.
|
|
|
|
|
Jörgen Sigvardsson wrote:
Uhm. You call this maintainable? CRC checksums?
With the proper tools, yes. All I have to do to update a string is highlight the checksum and corresponding string, including the comments, press a toolbar button and it's updated. Perhaps it's just me, but I dislike seeing a bunch of if statements. I'd rather see a switch. Note that I would not attempt this if I didn't have a add-in to regenerate the checksums. I even toyed with the idea of writing a small app that could be used in a pre-build custom step that would automatically refresh or generate any of the checksums. But I haven't run into any problems keeping up to date with the dozen of projects and numerous locations within each project. It just seems to work. If you have a better idea (and don't say a bunch of if's), then let me know. I realize it's not the most elegant, but it is quite efficient and, for me, quite readable.
Joel Lucsy
|
|
|
|
|
hey everyone, simple question
it seems like it should be so easy too, i just need to call use
CAboutDlg hey;
hey.DoModal();
from my main App Class.
its a dialog based project, and I get compilation errors like the app class cant see the cabout class.... please help, thanks
Deleting intermediate files and output files for project ' - Win32 Release'.
--------------------Configuration: - Win32 Release--------------------
C:\WINDOWS\Desktop\Eye.cpp(121) : error C2065: 'CAboutDlg' : undeclared identifier
C:\WINDOWS\Desktop\Eye.cpp(121) : error C2146: syntax error : missing ';' before identifier 'hey'
C:\WINDOWS\Desktop\Eye.cpp(121) : error C2065: 'hey' : undeclared identifier
C:\WINDOWS\Desktop\Eye.cpp(122) : error C2228: left of '.DoModal' must have class/struct/union type
EyeSpy.exe - 4 error(s), 0 warning(s)
todo....
:: insert inpirational text here ::
|
|
|
|
|
You need to #include the file that CAboutDlg is defined in.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
NEW: Awasu v0.7[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
it is included. thats whats strange, and was the first thing i checked.. ill post code when i get home tonight.
todo....
:: insert inpirational text here ::
|
|
|
|
|
Here's a weird bug: whenever I clean up my list control (before repopulating it with data), I loop through it and delete memory I allocated for each entry. At the same time, I make a call to the SetItemData() method. The code looks like this:
delete node;<br />
m_PhotoList.SetItemData(i, 0);
For some strange reason, when I do this my OnItemChanging() method gets called. In that method, I set some data (in the node that I created). Obviously, since I've just deleted the node (because I'm cleaning up the list control), an exception is thrown (for accessing memory not available).
Anyone have [b]ANY[/b] idea why this is happening? This has really gotten me stumped...
Jonah Bishop
Visit JGB Productions
|
|
|
|
|
LVN_ITEMCHANGING sends an NMLISTVIEW struct. The uChanged member tells you what changed in the item, so I bet if you inspect that member, it will contain LVIF_PARAM , meaning the LPARAM (ie, item data) changed. Your handler can ignore the notification in that case.
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I have a CFormView that has an edit control, and my program has an accelerator key binding to the Delete key. When I select a word in the edit control and press Delete, the accelerator binding is invoked rather than the word being deleted in the edit control.
So, in other words, I want the delete key to act normally when my edit control has the focus. How can I correct this problem?
Jonah Bishop
Visit JGB Productions
|
|
|
|
|
Do Arab fonts require UNICODE???
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I don't think so, if the system locale ( and codepage ) is set to some arabic language country/region, it might work. I know that the resource editor is not UNICODE, and will work in codepage.
but UNICODE will make life easier.
Max.
|
|
|
|
|
Thanks
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi,
I'm doing this project with ATL and I needed to use PumpMessage(..) but it's only available through MFC. So I looked at Mike Dunn's FAQ
http://www.codeproject.com/cpp/cppforumfaq.asp#ui_workerthread[^]
and did this:
void CSomeDlg::ProcessMessages()
{
MSG msg;
while ( PeekMessage ( &msg, NULL, 0, 0, PM_NOREMOVE ))
{
GetMessage (&msg, NULL, 0, 0);
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
And I'm calling every few lines of code. Looks to work ok... Is this safe?
Thanks!
|
|
|
|
|
It's pretty boiler plate. I reckon that is what MFC is doing, and I'm sure it's safe.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Boiler plate? I'm sorry, I'm not familiar with that expression!
Luc
|
|
|
|
|
It means code that is often needed and is always the same.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Yes, that's fine, although you can use the PM_REMOVE flag in the PeekMessage() call so you won't have to call GetMessage() right away.
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Sorry, I posted this a couple of days ago then disappeared. I didn't post much info either (the problem then was me being totally dippy) so I thought I'd risk the wrath of you lads and post it again with more info, save the flogging for later please
Anyway, short story is that I have to extract email addresses from a lot of files which have been exported from a database. There is no general format to these files, so its a hack & slash search to find them. The only things I have guarenteed is that there will be a space before & after the address and that the @ character will only be in the email addresses, not in any other fields. A sample of the file would be something like this but a lot bigger (roughly 2000 characters each) and they can contain more than one email address.
asd98a7098a70d98as abc-def@hotmail.com as8709-898 Dundee Geffen oiu7098
What I'm trying to do just now is write a ParseEmail(CString wholeFile) function that gets the file passed to it, and it works through picking out the email addresses. My problem is that CString isn't behaving how I would expect
while(whoIs.Find("@",0) != -1)
{
int index = whoIs.Find("@",0);
TRACE("@ character at position %d\n",index);
int end = whoIs.Find(' ',index);
TRACE("end = %d\n",end);
int pos = index-1;
CString ch;
ch = whoIs.GetAt(pos);
while(ch.GetAt(pos) != ' ')
{
pos--;
TRACE("ch = %s\n",ch);
}
CString email = whoIs.Mid(pos,end);
TRACE("email address = %s\n",email);
whoIs.Delete(0,end);
}
The problem after all this long windedness that the finding of the space before and after the @ doesn't work as I expect. It usually ignores spaces and other characters and returns me 50 letter email addresses
Does anyone have an idea of how I could improve this function so that it actually works? Cheers and sorry for the 10,000 word essay
|
|
|
|
|
Strange, this had a 1.0 rating. Anyway...
Perhaps try CTokenizer: http://www.codeproject.com/string/tokenizer.asp[^]
The code would be something like this:
CTokenizer tok( YOUR_INPUT_STRING, " " );
CString str;
while( tok.Next( str ) )
{
if( str.Find("@") != -1 )
{
}
}
|
|
|
|
|
Larry Antram wrote:
Strange, this had a 1.0 rating.
One of the great things about having a high post count is that my vote one a post counts for more than most people ( possibly everyone except Nish). I gave it a 5 to bring it back up. I don't get why some people vote posts the way they do.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|