|
I that a question? If so I believe the answer is yes.
Steve
|
|
|
|
|
Hi all,
for printing i taking help with this article.
http://www.codeproject.com/KB/printing/QPrint.aspx[^]
With the help of this article the printing is done,But there is no option of print preview.
I want to seen first privew then printing.
What can i do please help me for this.
Thank in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
I suggest you read Roger Allen's articles[^] - he's written lots about printing, and print previewing, and the complex code plumbing needed.
All you ever wanted to know about printing, and never dared ask...
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
I am a Chinese girl,study Programming presently.Last year,I graduated from university.Now I an a software engineer .My English is not very good,so I want to find a friend who can keep Email with me in English .Beacause I want to study English truely.
If you can help me,please write a letter to me.
My E-mail:yangjinna66@163.com
My MSN:halibobo-520@163.com
I am waiting for your letter! thank you!
//??????????? ,?????????????,??,??????,??????????????
|
|
|
|
|
This is not a grammar class and it seems you have read out queries in ENGLISH and !(read not) with C++ perspective. Look closely most of the questions are related to C++ however "THEY" (the programmars here) do use ENGLISH to convey their problems.
If your english is not good how come you wrote all those lines in your query.
halibobo wrote: My MSN:halibobo-520@163.com
Apart from COM(in your email id) there is nothing that resembles with C++/MFC/ATL in general
IMHO, you should try and look for some english tutorials and
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
modified on Thursday, July 10, 2008 3:42 AM
|
|
|
|
|
Thanks for your reply,From your talking, i have trust in the future,through I writing this reply spend much time.
"Apart from COM(in your email id) there is nothing that resembles with C++/MFC/ATL in general "
----I don't know others web I can write this message.
|
|
|
|
|
Hi all,
I got this problem
DWORD dwData, Type, Size, dwRet, BufferSize;
BufferSize = TOTALBYTES;
PPERF_DATA_BLOCK PerfData = (PPERF_DATA_BLOCK) malloc( BufferSize );
Size = BufferSize;
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, MPPARAM, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,&Regentry);
if (lResult == ERROR_SUCCESS) {
dwRet = RMRegQueryValueEx(Regentry, _T(SERIALNO), NULL, &Type, (LPBYTE) &dwData, &Size);
if( dwRet == ERROR_SUCCESS )
{
MPSerialNo = dwData;
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, MPSYSTEMKEY, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,&Regentry);
if (lResult == ERROR_SUCCESS) {
dwRet = RMRegQueryValueEx(Regentry, _T(MAJORVER), NULL, &Type, (LPBYTE) &dwData, &Size);
MPVerNo = dwData;
}
}
}
return;
My problem is that after the first RMRegQueryValueEx even if it is successful, dwData when passed its value to MPSerialNo which is an integer it crashes. MPSerialNo is first used here after declaration so therefore its value is some negative numbers then it becomes empty after the RMRegQueryValueEx.
Please advice
Thanks,
jayjay
|
|
|
|
|
Your code has some problems...the fifth parameter to RegQueryValueEx should be the buffer that receives the value, and the sixth parameter is an in/out parameter. This sixth parameter should contain the size of the fifth parameter on input.
In your first call, parameter 5 is &dwData, but the size is set to the size of your PerfData (TOTALBYTES). That is incorrect - dwData is only 4 bytes long.
In the second call, Size is now 4 (as set by the first call), which is the size of dwData (which you again passed as parameter 5). You can see this if you step through your code in the debugger.
I'm not sure why you malloc PerfData (in fact you should use "new" instead of "malloc"), but never use it - perhaps that should have been used in your second call? You also don't delete the PerfData before returning from the function, so you'll have a memory leak each time you call this function.
In any case, you should remember to reset your Size parameter each time before you call RegQueryValueEx.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi all,
I am new to this forum and generally any programming help forum for that matter.
I have a case where i want to maintain both C and C++ api library. So therefore i choose to make my C++ support a thin wrapper around the C code. However, i do not know what is the most effective way to achieve this without unnecessary memory and performance overhead. Below is an example case.
/*Begin Code Sample*/
/*Start time.h*/
struct Time
{
int seconds,
int nanoseconds
};
void timeAdd(struct Time* time, struct Time* delta);
void timeSub(struct Time* time, struct Time* delta);
/*End time.h*/
/*Start timer.h*/
struct Timer
{
struct Time time;
void (*callback)(struct Timer *timer);
};
void timerSetCallback(struct Timer *timer, void (*callback)(struct Timer *timer));
void timerStart(struct Timer *timer);
void timerStop(struct Timer *timer);
/*End timer.h*/
/*Start time.hxx*/
namespace C
{
#include "time.h"
}
class Time
{
public:
Time()
{
m_time.seconds = 0;
m_time.nanoseconds = 0;
};
~Time(){};
int seconds(){return m_time.seconds;}
int nanoseconds(){return m_time.nanoseconds;}
void setSeconds(int seconds){m_time.seconds = seconds};
void setNanoseconds(int nanoseconds){m_time.nanoseconds = nanoseconds};
void add(Time &time){C::timeAdd(&m_time, &time.m_time);};
void sub(Time &time){C::timeSub(&m_time, &time.m_time);};
protected:
C::Time m_time;
};
/*End time.hxx*/
/*Start timer.hxx*/
#include "timer.h"
class Timer : public Time
{
public:
Timer():Time(){m_timer.callback = &Timer::callback;};
~Timer(){C::timerStop(&m_timer);};
start(){m_timer.time = m_time; C::timerStart(&m_timer);};
stop(){C::timerStop(&m_timer);};
protected:
static void callback(struct Timer *timer);
C::Timer m_timer;
};
/*End Code Sample*/
Now while this works for this simple case, it has a few drawbacks like the additional memory used to allocate m_time in class Time when all of struct Time api's would have even worked for struct Timer and hence struct Time m_time could have been "replaced" by struct Timer m_time but instead both exist in class Timer.
It also is the simpler of the cases where the struct sizes are relatively small and the call to Timer::start() was easily managed by a copy of the struct.
So now, my question is how can c++ wrappers be written for such cases without the additional memory overhead? Given their similarity, I definitely want class Timer to be a subclass of class Time!
However, i do have the flexibility to modify both the C and C++ code but i need both the C and C++ code to be equally capable, clean and efficient. How can i do it?
|
|
|
|
|
In case you don't know in C++ struct and class is basically the same thing. There is only one difference - in struct the default access is public while in class default access in private. So you can write code like this.
struct Time
{
int seconds,
int nanoseconds
};
void timeAdd(struct Time* time, struct Time* delta);
void timeSub(struct Time* time, struct Time* delta);
class CTime : protected Time
{
CTime()
{
seconds = 0;
nanoseconds = 0;
}
};
Hope this helps.
-Saurabh
|
|
|
|
|
Yes. I am aware of that. So that is easy when i have to create class Time but then what do i do with class Timer?
Cheers!
Kishore
|
|
|
|
|
With the code you provided I don't think you cannot wrap Timer in C++. Can you share how about about how timer callback is used?
-Saurabh
|
|
|
|
|
Saurabh.Garg wrote: With the code you provided I don't think you cannot wrap Timer in C++. Can you share how about about how timer callback is used?
The code that i present here is not the actual code i use but is similar. With regard to the callback, i am currently exploring the use of the code i found from an article here on FastDelegate.
Cheers!
Kishore
|
|
|
|
|
Yes for member function callbacks you need delegates. I didn't suggest that earlier because I was not able to think how you would write a wrapper in C++ using delegates over C structures. I think you can port the code to C++, meaning the C and C++ code bases will be different.
I myself use delegates from Fast C++ Delegate[^]. There are lots of delegates article on code project but I find this one to be easiest to use.
-Saurabh
|
|
|
|
|
Hi,
you're doing something i don't get.
on the C Side you got
struct Time
{
int seconds,
int nanoseconds
};
and
struct Timer
{
struct Time time;
void (*callback)(struct Timer *timer);
};
The Timer struct encapsulates the Time struct, because in C you don't have inheritance. This is correct. But on the C++ side you got
class Time
{
public:
...
...
protected:
C::Time m_time;
};
and
class Timer : public Time
{
public:
...
...
protected:
static void callback(struct Timer *timer);
C::Timer m_timer;
};
Here you make some design error.
The class time encapsulates the 'c' Time struct and giving it some extra functionality. No problem so far. But you're class Timer inherits from the Time class and encapsulates the 'c' timer struct.
Giving you indeed twice the 'c' time struct. According to me this is a fault in the design. The 'C' and 'C++' counterparts are NOT equivalent.
To make the equivalent you should encapsulate either the 'C' Timer struct, or, inherit from the Time class and adding the needed Callback function. But you can't do both.
Why do you inherit from the time class?
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
<quote>Here you make some design error.
The class time encapsulates the 'c' Time struct and giving it some extra functionality. No problem so far. But you're class Timer inherits from the Time class and encapsulates the 'c' timer struct.
Giving you indeed twice the 'c' time struct. According to me this is a fault in the design. The 'C' and 'C++' counterparts are NOT equivalent.
To make the equivalent you should encapsulate either the 'C' Timer struct, or, inherit from the Time class and adding the needed Callback function. But you can't
You are absolutely right. This is the exact problem that i want to solve when writing C++ wrappers.
<quote>Why do you inherit from the time class?
Because the many API's associated with class Time are are also applicable for class Timer. Also, the code presented here is one of the simpler case. The other code that i use also have similar use cases but are somewhat more complex.
Cheers!
Kishore
|
|
|
|
|
I have an existing C++ mfc program that I need to modify. I need to make it parse an xml file to look for certain data. I have found that it is easier to do this parsing of the xml file using a vbscript. I am looking for a way to call the vbscript in my c++ code and capture return data from the script. Does anyone know how to do this? Or is there an easy way to search xml files using the old visual c++?
Rock
|
|
|
|
|
rocktx wrote: I have found that it is easier to do this parsing of the xml file using a vbscript.
Not so much. You would have to host a scripting engine to do that. Therefore it seems working with the MSXML interfaces would be simpler. Start with the following link, that page and all it's child pages should provide you with everything you need.
Get Ready to Work with MSXML (C/C++)[^]
led mike
|
|
|
|
|
I'm having a play with GDI+ drawing in one of my Apps.
I have an arbitrary region (made up of all sorts of wacky shapes) that I can draw semi-transparently over a bitmap using a brush with Alpha=64, and Graphics::FillRegion method.
Class GDI has a FrameRgn call which draws an outline of a region, but I can't find an equivalent in GDI+. While I could convert a Region to an HRGN, I'd lose some capability like scaling, which I need.
Has anyone solved this before? Am I being blind and missing some way of saying "you know that thing you're about to do? Use a hollow-but-edged-brush"...
Thanks,
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
GraphicsPath::Outline() is the closest I've found.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark.
I'll have a proper look tomorrow.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
I need to get the privilage set of user (Administrator,Guest ...)
Is any API is there to achieve this .. ?
vineesh
|
|
|
|
|
There's been several IsUserAnAdmin questions in the last few days...
Have a look at this reply to a question two days ago:
http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2628859[^]
Don't forget to look at the other answers too for information.
Going through the security SDK is a difficult thing. Lots of pointers and SID, and xIDs, and, and, and...
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
vineeshV wrote: I need to get the privilage set of user (Administrator,Guest ...)
You can use NetUserGetInfo() for this.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi to all,
namepsace MyNamespace
{
class A
{
public :
void FunA();
};
class B
{
void FunB();
friend void A::FunA();
};
}
Above code compiles successfully.
But below given code generates error as error C2027: use of undefined type 'MyNamespace::B'
Please help me to resolve error in following code?
I am using VC++ 2008.
namepsace MyNamespace
{
class B;
class A
{
void FunA();
friend void B::FunB();
};
class B
{
public :
void FunB();
};
}
Thanks in advance.
Best Regards,
Aniket A. Salunkhe
|
|
|
|