|
i tried adding the manifest file to the project,but it doesn't work.
i guess there must be something else to do to make this.
modified 1-May-21 21:01pm.
|
|
|
|
|
You must call InitCommonControls() at the start of your program.
Software Zen: delete this;
|
|
|
|
|
So, I'm experiencing the blackout of my life.
I currently perform a code review and got stuck on the following (I did a couple of simplifications for this CP demo purpose):
char* pText = "";
if(...condition A...)
pText = "Some text";
else if(...condition B...)
pText = "Another text";
I don't use this style myself, because I've been taught not to.
My understanding of the above code is that asignment 1 is ok to do, because the compiler will tell the program to allocate memory for "" at startup and point pText to that memory. However, I 'm stumbling on the "correctness" of assignments 2 and 3 - will they segfault at some time, or are they completely and utterly safe and legal? I could imagine that memory is also allocated for those texts at startup, so that redirecting pText to one of them will be safe after all.
Gee, I really feel 15 years less experienced than I am right now...
Thanks for any input.
|
|
|
|
|
I don't think assignments 2 and 3 are legal at all. Imagine for a moment if you had the following statement:
char cSomeChar;
pText[ nSomeIndex ] = cSomeChar;
Either one of those strings is considered a constant so you can't really alter their values.
Assume for a moment that pText will point to another text string later. Will the compiler deallocate and reallocate memory for the pointer again? How will it distinguish from a case where memory is being allocated by the programmer or by the compiler? It would have been great if compilers had those capabilites, but to my knowledge there aren't any that can do that. That's why I believe those assignments are totally illegal. To tell you the truth you are making me question what I know about pointers (which isn't a lot ).
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Toni78 wrote:
I don't think assignments 2 and 3 are legal at all
Actually, after some thought, I'm quite convinced that the assignments 2 and 3 are legal and safe, since they point to string literals allocated at startup.
But another question is whether this is a Good Style or not...
|
|
|
|
|
I don't see any problem with memory allocation but should pText be
initialised to "" or NULL. If you set char* pText=NULL and later
try to use it then the program crashes(MFC). pText="" will not crash
but it can be more difficult to debug.
jhaga
|
|
|
|
|
Because "Some text" and "Another text" are static text, the compiler has already made room for them. pText can point to them because they indeed exist in memory.
|
|
|
|
|
The code is legal but not safe. You should use a const char * (LPCSTR) to point to this string to signify that the contents should NOT be modified.
|
|
|
|
|
In my header file I have:
<br />
#include <iostream><br />
#include <list><br />
<br />
class mp {<br />
private:<br />
class element {<br />
public:<br />
double x;<br />
double y;<br />
double z;<br />
bool operator<(const element& a ) { return z < a.z; }<br />
friend std::ostream& operator<< (std::ostream& str, <br />
const element& e ) <br />
{<br />
return str << "(" << e.x << "," << e.y << "," << e.z <<<br />
")";<br />
}<br />
};
typedef std::list<element> elementList;<br />
elementList points;<br />
public:<br />
mp();<br />
mp( elementList Points );<br />
void print();<br />
};<br />
in my cpp file I have:
<br />
#include "mp.h"<br />
<br />
mp::mp() {}<br />
<br />
mp::mp( elementList Points ) {<br />
points = Points;<br />
points.sort();<br />
}<br />
<br />
void mp::print() { <br />
using std::cout;<br />
for ( elementList::const_iterator e = points.begin(); e !=<br />
points.end(); e++) {<br />
cout << e << endl;<br />
}<br />
}<br />
Get get this error ....
error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::list<class mp::element,class std::allocator<class mp::element> >::const_iterator' (or there is no
acceptable conversion)
what do you think?
please help me out
|
|
|
|
|
try
cout << *e << endl;
instead.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
|
How can I send mail with win32? Not with MFC.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Search for articles on SMTP.
|
|
|
|
|
In addition to SMTP, search for (Simple) MAPI, and CDO.
|
|
|
|
|
hi, i'm trying to display bitmaps using Raw RGB values. I don't know how to create a bitmap using RAW RGB values in c++ though.
I'm new to c++ so if you could help me out it would be a great help.
|
|
|
|
|
Search codeproject for using DIB sections. Other than that I have no idea what you are talking about.
Trust in the code Luke. Yea right!
|
|
|
|
|
The control/class is available for VC++6 or VB6.
Thanks
DJ
|
|
|
|
|
you may use MicroSoft MAPI controls!!
Take help on Microsof MAPI controls.
or
you may user outlook API's / Office API's to send the mail. But it will be confined to outlook only.
Vikram
|
|
|
|
|
I'm creating a few thread pool classes in which I want to be able to suspend/pause a thread that is waiting for work to do. [the different classes are basically different methods of handling high workload or simple static thread-pools etc that map down to a single interface for access. Btw, if there's any novel ways that you have, I'd be glad to know them too, so I can expand the Interface implementations.]
The SuspendThread/ResumeThread method is what I currently have implemented as doing that, but I cannot find any information on performance relating to using these functions, particularly frequent calls to them. I saw some data about it and the .Net implementation, which said that its SuspendThread and ResumeThread weren't all that safe to use due to unknown-stop points [though so far to me it seems it operates right in the raw Win32 version.. though I havent run many tests]
|
|
|
|
|
I did some reading in the MSDN library and it seems I could use WaitMessage and post messages to the thread to awaken it and also have work to queue [such as passing the address to a job instance as one of the message values]
Does this sound reasonable and would have good performance as opposed to any other method? To me it looks like no kernel objects are used [besides the thread itself] which seemed to be the biggest hit in performance of methods.
|
|
|
|
|
You should rarely, if ever, use SuspendThread/ResumeThread. It creates a system that is entirely unpredictable and which will be prone to all sorts of problems, including synchronization problems.
Generally, you should use either i/o completion ports and/or events with WaitForMultipleObjects inside the thread (one event should be a shutdown event so you can signal the thread to clean up and shut down.)
|
|
|
|
|
Thanks. I found a Thread class that implemented an Interrupt function and found that it used APC queuing, which I didnt think about before. I didnt get to see it's code though because it was a big-ol-library that was for sale. But i looked on MSDN and found that Queueing an APC function would break alertable wait functions, such as SleepEx [which i used]. I implemented an Abort function which the APC function calls a cleanup function inside the "job" so that things can get cleaned up. I also implemented a simple Interrupt function which the APC function does nothing i.e. Foo() { } so that all it did was break the sleep.
[Since I was using member functions I had to wrap the function in a way that a static function was given the 'this' ptr and that was used in accessing the cleanup function, etc.
|
|
|
|
|
Can someone tell me how to convert COleFont to CFont? I really don't know much about OLE objects.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Hi all.
I have a DialogBar which I've added to my SDI application. I create the Dialog resource with some text areas and buttons in Resource View and add it to the application, docked at the bottom. All is well. However, the buttons are grayed out as though they're disabled. I can get a handle to the CButton at runtime and it does indeed think its enabeled. Checkboxes, radio buttons, list boxes, etc. all seem to work without looking disabled. What's the deal?
Code that adds the dialog bar, in CMainFrame::OnCreate :
if (!m_wndTransBar.Create(this, IDD_TRANS_BAR, CBRS_BOTTOM, IDD_TRANS_BAR)) {
TRACE0("Failed to create translation bar\n") ;
return -1 ;
}
|
|
|
|
|
Have you added handlers for your toolbar to the mainframe class
ON_COMMAND_RANGE(ID_DYNAMIC_START, ID_DYNAMIC_END, OnDynamicCommand)ON_UPDATE_COMMAND_UI_RANGE(ID_DYNAMIC_START, ID_DYNAMIC_END, OnUpdateDynamicCommand)
???
Brian
|
|
|
|