|
yup ... catch the OnCtlColor(...) message and set the dc brush properties to what you require
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I have put my stuff in OnCtlColor (parent control) and it works
Thanks Lauren!
bye
Miha
Random code generator is the way to go
|
|
|
|
|
I have implemented printing within a MFC application.
I have a weird problem.
When I paint (BitBlt) a bitmap the Print Preview works OK.
However when I Print the page, only a black rectangle appears.
Apparantly I am doing something wrong.
Does someone had a similar problem and found the solution.
Thanks in advance,
Bert
|
|
|
|
|
Hello,
if you ware working with a variable parameter list like (int Number,...) how can you programmatically find out the number of parameters specified?
MSDN Help for va_arg, va_end, va_start does it in the following way using -1 as an extra not processed last parameter.
int average( int first, ... )
{
int count = 0, sum = 0, i = first;
va_list marker;
va_start( marker, first ); /* Initialize variable arguments. */
while( i != -1 )
{
sum += i;
count++;
i = va_arg( marker, int);
}
va_end( marker ); /* Reset variable arguments. */
return( sum ? (sum / count) : 0 );
}
Are there better ways without a finishing last dummy parameter?
--- Rainer Mangold
|
|
|
|
|
The other way is to pass # of arguments as one of 'normal' parameters. However, this increases the probability of an error - you could add one param and forget to increase passed # of param. Generally, you have to know what called function expects on the stack - there's no way to detect this 'automatically'.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thanks a lot,
this was the answer I expected, although I hoped that there would be a nicer solution.
-- Rainer
|
|
|
|
|
Gurus (if I may call you that )
As a newbie to MFC, should I stop! and start to learn .Net with C++ ?
Or even drop C++ for C#
This takes a big investment in time, and I don't want to learn MFC if its going to die RSN.
Does .Net have a Application Framework like MFC ? If so, is there a C++ specific one or is the framework for ALL langauges now ?
Any pointers greatfully recevied.
|
|
|
|
|
Hello, the codegurus around the world.;)
My basic question is why you want to learn the computer language like C++, C# or so on.
If you want to be the programmer, to learn MFC isn't in vain.
Software company is always looking for a more talented programmer, and
if the applicant has to the ability to write the code by more language,
he or she can find the job more easily.
Besides, C# is still "BETA" version, and I doubt how many companies pick up C# ASAP for
its project as well as how valuable the programmer only know C#.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
C# is not everything, it is not attempt to replace MFC, it is a good complementarity. I think C# is good choice to develop web application, but isn't appropriate to develop a system such as CAD system. C# is compiled at load time, it consume too much time to startup an application, while it isn't a problem in web application.
To MFC or not? the answer is all depend on what you want to do in the future.
|
|
|
|
|
I'm trying to parse a text file (using ANSI C) and extract every word aand insert into link list. Where can I get to see some sample code showing this type of parsing?
TIA.
Hush..Hush.. thought I heard you calling my name now...
|
|
|
|
|
Hi !
If it's acceptable for you to use ANSI C++, the solution is below:
#include <fstream>
#include <string>
#include <list>using namespace std;
int main()
{
ifstream inputfile("readme.txt");
istream_iterator<string> isi(inputfile), iseof;
list<string> ls;
copy(isi, iseof, back_inserter(ls));
return 0;
}
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
becase forume eats some brackets - here is the repost... I think you know that symbols should be instead of "[" and "]"
#include [fstream]
#include [string]
#include [list]
using namespace std;
int main()
{
ifstream inputfile("readme.txt");
istream_iterator[string] isi(inputfile), iseof;
list[string] ls;
copy(isi, iseof, back_inserter(ls));
return 0;
}
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
Thanks. But I need to implement parsing in ANSI C without STL. Could any og you pass me a link to some code?
Hush..Hush.. thought I heard you calling my name now...
|
|
|
|
|
for parsing u can use strtok. u can get token string from a bigger string based on a known seperator
char *buffer; // buffer to parse
char *token; // the token string
char sep[]=" "; // here seperator is space
...
token = strtok(buffer,sep);
while(token != NULL)
{
... process token
token = (NULL,sep);
}
I hope this is what u r looking for
|
|
|
|
|
Hi all.
How can i convert char * variable to OLECHAR * variable ???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi Hadi !
Try this macro: A2OLE and take a look at "String Conversion Macros" article in MSDN.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
I read this article, but i didn't understand !!!
Can you write an example ???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hmm. Here it is :
USES_CONVERSION;
OLECHAR* pOLECHAR = A2OLE("example");
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
I got 3 errors:
error C2440: 'initializing' : cannot convert from 'int' to 'unsigned short *'
error C2065: 'A2OLE' : undeclared identifier
'USES_CONVERSION' : undeclared identifier
Are you sure i don't need with any header file ???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
try #inlclude <atlconv.h>... but I'm not sure is it posssible to include this file directly ... Is your project ATL-based ?
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
My program is MFC mode.
I think wchar_t is equal with OLECHAR ...
Does i have not any other way ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
include [atlconv.h] file into your source file and try A2OLE macro.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
Excellent ...
Thanks aloooooooot for your answers and your time.
Now, my program will work, perfectly ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Please be aware that you should NOT use OLE2A in a tight loop.
This is will propably crash:
void main()
{
USES_CONVERSION;
LPSTR sz="";
BSTR bstr = L"Goodbye, World...";
for (int i=0 ; i<100000 ; i++)
sz = OLE2A(bstr);
}
The reason is that OLE2A allocates memory on the stack for performance reasons, so you will run out of stack space if you do not take care to leave scope once in a while.
Instead, put your OLE2A macro in a separate function, where it is certain that it will not be called several times without leaving scope - or use dynamically allocated mamory (slower but safer).
Christian Skovdal Andersen
|
|
|
|
|
Just one quick comment on the ATL convertion macro's.
They alloc the string on the stack, using _alloca(), so they are no good for long strings, or when used in a loop...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|