|
Thanks, that did the trick. So it looks like preprocessor logic is possible, as long as you use defined constants, not variables.
|
|
|
|
|
Hello all,
I am fairly new to Visual C++ and MFC.
I have learnt the basics.
I would like to write a text editor based on CRichEdit if possible or CEdit.
As I would prefer not to reinevnt the wheel, I would like to start from a basic notepad-like application and modify it.
Does anyone know where I can find the source code of a basic editor?
I have browsed a bit but only found the code for Write on the Microsoft website which does not work on my machine.
Many thanks.
Giulio
|
|
|
|
|
Use the wizard to generate an SDI app and in the options, change the CView class to CEditView or CRichEditView.
Regards,
Nish
|
|
|
|
|
Giulio2000 wrote: As I would prefer not to reinevnt the wheel, I would like to start from a basic notepad-like application and modify it.
GOOGLE[^] is your friend buddy
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hello
I want to write a driver that will:
1. Catch certain packets (UDP and TCP) that been sent by my host.
2. Add to their data additional information.
3. Change accordingly the checksum.
4. Resend the packets.
The driver should be windows based, and in kernel mode of course.
My questions are:
1. Do I need to write a filter hook driver?
2. Can anyone help me in starting to write this kind of driver (never written a driver)?
3. I read about IPsec driver, and I think its doing something similar. Does this information help me? In addition, if it does, how can I get its source, or maybe a related source of a driver doing similar operations.
Thank you
|
|
|
|
|
you can never just add some information to a udp or tcp packet. They all have a size limit, which is normally given by the network hardware. This will cause many packets to be oversized, so they have to be split... it's more complicated than you might think to do such a thing.
Don't try it, just do it!
|
|
|
|
|
I am trying to debug a program that captures live video from my webcam. As soon as I try to initialize the filter group, a message box pop ups displaying "Protection error -debugger detected please close it down and restart". I think that some dll (maybe the webcam drivers?) has some kind of protection against reverse engineering. How can I know what is the dll causing this?
Thanks.
--
Miguel A. Vilariño
Software Developer
|
|
|
|
|
You could run a disassembler on them and see if they link to IsDebuggerPresent . That is an API your program can call at runtime to see if it is being debugged.
|
|
|
|
|
|
I ran into some linker warnings about multiply defined symbols in a very large application (20 VC projects). I tracked it down to someone defining a function within the header file. I personally think it's lazy coding but that's just my opinion and we all know what those are....
<br />
#pragma once<br />
class Foo<br />
{<br />
public:<br />
Foo();<br />
virtual ~Foo();<br />
<br />
int GetBar() const { return m_value; };<br />
<br />
private:<br />
int m_value;<br />
};<br />
The header file is used across multiple static library projects. Each static library exports the symbol Foo::GetBar. The application project then links in all the static libraries spitting the warnings LNK4006. Does anyone have a technical explanation why the #pragma once doesn't prohibit this type of error and/or why each static library exports Foo::GetBar? Thanks.
harrier
-- modified at 12:12 Thursday 12th January, 2006
|
|
|
|
|
#pragma once only causes the header to be included a single time per compilation unit. Each source file is a separate compilation unit. A static library is a collection of one or more compilation units.
Each static library contains Foo::GetBar because each one included the header file to get the definition of Foo.
If you did not think GetBar would ever be overloaded by a dervied class, I would just tag that sucker as inline and get it over with.
Marriage slows down your coding, a baby slows it down even more!
|
|
|
|
|
Blake Miller wrote: Marriage slows down your coding
maybe...
Blake Miller wrote: a baby slows it down even more!
...but it's so sweet that it shouldn't even be compared to...
when you don't give time to you compiler, it will stay as is.
if you don't give time to your baby, he will grow up with a missing father !
make your choice.
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
|
Blake Miller wrote: If you did not think GetBar would ever be overloaded by a dervied class, I would just tag that sucker as inline and get it over with.
thats interesting - I wouldnt have thought of that if it had been me - I would have ripped the function implementation out into its own cpp
the things you learn by sitting back and watching sometimes
cheers, Garth
|
|
|
|
|
implementing the function in the class itself are called inline functions.
-Prakash
|
|
|
|
|
thanks Mr P. I knew that (what inline was) - I didnt know that making it inline would get around that particular 'multiple define' issue
'g'
|
|
|
|
|
#pragma once just causes the compiler to process an include file only once per build... that has nothing to do with the linker.
Don't try it, just do it!
|
|
|
|
|
Hi
I get from an application a UTC time value in the following variables : nyear, nmonth, nday, nhour, nminute, nsecond.
I need to convert this UTC time value in a time_t format (also UTC), whatever the time zone and the DST of the computer.
I've tried with a CTime object, but CTime::GetTime() considers that it contains a local time, and take into account the time zone. (I can only remove the DST effect)
Thank you for any idea ?
Jérôme
|
|
|
|
|
I think if you first fill a SYSTEMTIME structure with the nyear, nmonth, nday... values then use it in your CTime constructor your times will work.
ie.
<br />
<br />
SYSTEMTIME st;<br />
st.wYear=nyear;<br />
st.wMonth=nmonth;<br />
st.wDay=nday;<br />
st.wHour=nhour;<br />
st.wMinute=nmin;<br />
st.wSecond=nsec;<br />
CTime mytime(&st);
<br />
Regardless if that particular method works or not. If you use SYSTEMTIME object there's a bunch of functions available to go back and forth between time zones that may make your life easier.
|
|
|
|
|
Thank you for your answer.
When creating "CTime mytime(&st);" with the SYSTEMTIME st value I assume that the CTime constructor takes into accout that the given time is UTC time, and it must apply the local time conversion ?
So when I execute time_t t_utc = mytime.GetTime(), I get a UTC time in t_utc ?
Is it the way it works ?
|
|
|
|
|
Well, like I said before, it's been a while since I've used time structures and objects, but I have used them extensively in the past.
If you Do just a little playing around and debugging the SYSTEMTIME variable (it's easiest because all the members are .hour, .min, .sec and you can watch the values directly) I'm fairly sure will reveal that it always works in UTC timezone. The companion functions Format() etc. all add in timezone offsets.
This means you're thinking a little backwards as to when the timezones come into play, but it depends on which actual Structure or object you are talking about.
Just do a little debugging, it will become clear very quickly.
Oh and do yourself a favor, leave yourself lots of comments so you remember later. I looked through my old source and I forgot that part which is why I can't answer your question directly
|
|
|
|
|
I've finaly found a solution :
time_t system_time, time_tloc, time_tgmt;
struct tm loctime, gmttime;
time(&system_time);
loctime = *localtime(&system_time);
gmttime = *gmtime(&system_time);
time_tloc = mktime(&loctime);
time_tgmt = mktime(&gmttime);
long offset = time_tloc - time_tgmt;
CTime t(nAnnee,nMois,nJour,nHeure,nMinute,nSeconde, -1);
time_t lRetValue = t.GetTime() + offset;
Thank you for your help.
Jérôme
|
|
|
|
|
try GetLocalTime and GetSystemTime Api
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
how do i clear the keyboard buffer? i tried fflush(stdin) , _flushall(), nothing's working what could be the problem??
0x0400:
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
|
|
|
|
|