|
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
|
|
|
|
|
Aha! Didn't know that just not adding a handler would cause it to draw disabled. Thanks much for the help.
- Matt
|
|
|
|
|
Can anyone please tell me why this isn't working? It compiles fine and runs, but the close button doesn't get "greyed out".
#include "stdafx.h"
#include "CELL v2.h"
#include "windows.h"
#include "tchar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
using namespace std;
CWinApp theApp;
char buf[100];
void CloseMenu(){
wsprintf(buf,_T("CELL"));
SetConsoleTitle((LPCTSTR)buf);
HWND hwnd=NULL;
while(NULL==hwnd)
hwnd=::FindWindowEx(NULL,NULL,NULL,(LPCTSTR)buf);
SetConsoleTitle (_T("CELL"));
HMENU hmenu=GetSystemMenu(hwnd,FALSE);
DeleteMenu(hmenu,SC_CLOSE,MF_BYCOMMAND);
}
int _tmain(int argc,TCHAR* argv[],TCHAR* envp[]){
int nRetCode=0;
if(!AfxWinInit(::GetModuleHandle(NULL),NULL,::GetCommandLine(),0)){
cerr<<_T("Fatal Error: MFC initialization failed")<
|
|
|
|
|
You might just need to redraw the frame. Try manually switching to another window then switching back to your console to see if it's really getting grayed out or not. If you want to do it from code (the code I posted you yesterday had this call in it):
::SetWindowPos( hwnd, NULL, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_DRAWFRAME );
Chris Richardson
You can stash and you can seize
In dreams begin, responsibilities U2 - Acrobat[^]
Stop being PC and accounting for everyone and his momma's timeframe. Just enjoy your - Rohit Sinha in the content-challenged thread
|
|
|
|
|
I'm trying to get values out of the registry, using CRegKey, and I'm able to get number and string values from the registry, but when ever I try to QueryValue a binary value the QueryValue fails. I can't seem to get it to work no matter what I try.
Thanks in advanced
There's always one more bug.
|
|
|
|