|
why don't you simple put the CArray inside another class ? Me think it will make thing easier in the long run.
Watched code never compiles.
|
|
|
|
|
You can't write:
CArray myArray;
and expect it to compile without without telling it what you want to put in your array. You have to write something like:
CArray<int> myIntArray;
So the question is what type of data are you trying to store in your nested CArrays? Once you know that you can explicitly specify the type of your data in CMap. When you've done that you'll probably run into trouble because CArray hasn't got a copy constructor and I think the types supplied as arguments to CMap need to be copy constructable.
As a complete aside, how about binning this last century MFC collection class rubbish and use the standard library classes std::map and std::vector? They can do what you want with much less farting around than MFC.
Cheers,
Ash
PS: Thanks for Paul below pointing out the faux pas in the original post!
modified on Saturday, September 25, 2010 7:05 AM
|
|
|
|
|
Ash, I'm sure you meant:
CArray<int> myIntArray ...Though this syntax might be an interesting proposal for the 'central comitee' Otherwise I completely agree with the preferable usage of the std elements. My experience shows that an investment into refactoring code which uses custom (own or other non-standard) containers pays off really quickly...
|
|
|
|
|
Thanks for spotting the error, I should never write code without pairing these days!
Cheers,
Ash
|
|
|
|
|
Hi guys, I am writing project for bank operation in MFC, before running my application i have to check the username and password. But i have some problem in my code, my main frame window is closed after enter username and password.Any one tell me the reason.....
class CLoginDialog : public CDialog
{
};
CBankFrameWnd : public CFrameWnd
{
};
class CBankApp : public CWinApp
{
public:
CBankApp();
~CBankApp();
BOOL InitInstance();
};
CBankApp::CBankApp
{
}
CBankApp::~CBankApp()
{
}
BOOL CBankApp::InitInstance()
{
CLoginDialog *pDlg = new CLoginDialog();
m_pMainWnd = pDlg;
if(pDlg->DoModal() == IDOK)
{
if Valid User then assign frame window in m_pMainwnd and return TRUE ...
CBankFrameWnd *pWnd = new CBankFrameWnd();
m_pMainWnd = pWnd;
pWnd -> ShowWindow(m_nCmdShow);
pWnd -> UpdateWindow();
return TRUE;
}
else
return FALSE;
}
Thanks in Advance
|
|
|
|
|
Maybe the constructor of the window does not create it ?
virtual void BeHappy() = 0;
modified on Friday, September 24, 2010 2:19 AM
|
|
|
|
|
Hi all,
i m increase the row height of ListCtrl with using of this code.
1.Change the style of list control to "owner draw fixed" style!
2. m_RowList.ModifyStyle( LVS_OWNERDRAWFIXED, 0, 0 );
3.
void CDialogGuineaPig::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
if( nIDCtl == IDC_ROWLIST )
{
lpMeasureItemStruct->itemHeight += 10;
}
}
this is working fine but when i use CheckBox style in List ctrl its not working please tell me how can i increase List Row height with Checkbox.
please tell me how can i do this.
thanks in advance.
|
|
|
|
|
Hi All,
I want to know an API which can convert time in certain time zone to GMT/UTC.
Not the API which will use local system time zone to convert to GMT.
My input time may be in EST, CST, etc...
And I know the time zone of the time object I have, so I need an API which can convert this time to GMT.
I came across below API but I'm not sure about how to use it, mainly the first paramater.
SystemTimeToTzSpecificLocalTime
Thanks
Do your Duty and Don't expect the Result
|
|
|
|
|
You probably want this[^] and this[^]. If you need more, choose from the list here[^].
And read the documentation page on the functions you decide to use!
|
|
|
|
|
Hi,
I have a manifest with "asInvoker" privileges, the application will then run under a non-privileged token and no UAC dialog pops up at start. But there is one functionality where the application needs higher privileges later, right now this API call fails with ERROR_ACCESS_DENIED . I would like to change the application so that only for this functionality the UAC dialog pops up.... elevate process privileges for a short time.
Apparently you have to create a new process, then perform administrative tasks and return to your first process (MSDN, Stackoverflow). I am new to UAC, there isn't any simpler way?
Cheers
|
|
|
|
|
Moak wrote: I am new to UAC, there isn't any simpler way?
AFAIK, no; not unless you want to run the entire app with admin privileges.
L u n a t i c F r i n g e
|
|
|
|
|
Thanks everyone for their feedback!
|
|
|
|
|
The execution privilege is associated with a process token.
This is the reason why the manifest property is ignored if given to a DLL.
So you will either need to run the first process entirely with admin privileges or use a second program like you said.
|
|
|
|
|
It is very comfortable,
to let an app run "asInvoker"
However, it needs a service helper (started by SYSTEM) for the admin calls...
Not before (only there) you can call, for example, ::AdjustTokenPrivileges(..)
virtual void BeHappy() = 0;
|
|
|
|
|
I haven't coded my test program yet, from what I read creating another process with ShellExecuteEx and "runas " should do the runtime elevation. Can I ask, what for would I use AdjustTokenPrivileges() in an elevated process?
|
|
|
|
|
I set the cursor to IDC_WAIT but that shows me the hourglass cursor. However I want to show the arrow+hourglass cursor, where it is has both the arrow and the hourglass, but I can't find the ID for this cursor. Does anyone know what the ID is (i.e. IDC_what???)
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
|
hello guys....I had been working on this but this did't work. Well this should work now. This is a small TAPI app which if, I call on my lanfline #, should print something
void WINAPI TapiInitialize() {
LPLINEDEVCAPS lineDevCaps = NULL;
lineDevCaps = (LPLINEDEVCAPS)LocalAlloc(LPTR, 4096);
lineCallStatus = NULL;
lineCallStatus = (LPLINECALLSTATUS)LocalAlloc(LPTR,4096);
EventReply = CreateEvent(NULL,FALSE,FALSE,NULL);
memset(&LineInitializeExParams,0,sizeof(LINEINITIALIZEEXPARAMS));
LineInitializeExParams.dwTotalSize = sizeof(LINEINITIALIZEEXPARAMS);
LineInitializeExParams.dwOptions = LINEINITIALIZEEXOPTION_USEEVENT;
TapiEvent = LineInitializeExParams.Handles.hEvent;
if(TapiEvent==NULL)
printf("\nTAPI event could not be created....");
else
printf("\nTAPI Event Created....");
result = lineInitializeEx(&lineApp,NULL,(LINECALLBACK)lineCallbackFunc,NULL,&numDevs,&tapiVersion,&LineInitializeExParams);
if (result!=0)
printf("TAPI could't be Initialized");
else printf("\n\nTAPI Initialized..");
num = numDevs;
printf("\nNumber of lines available to this app: %d",(LPWSTR)num);
result = lineNegotiateAPIVersion(lineApp,0,API_EARLY_VERSION,API_CURRENT_VERSION,&tapiVersion,0);
result = lineGetDevCaps(lineApp,0,tapiVersion,0,lineDevCaps);
result = lineOpen(lineApp,0,&hLine,tapiVersion,0x00000000,0,LINECALLPRIVILEGE_MONITOR,LINEMEDIAMODE_DATAMODEM,NULL);
if(result!=0)
printf("\n\nLINE could't be Opened...");
else
printf("\n\nLINE Opened...");
result = lineGetStatusMessages(hLine,&lineStatus,0);
if(result==0)
printf("\n\nGetting line status...");
else printf("\nError: Line status not getting...");
}
VOID CALLBACK lineCallbackFunc(DWORD hDevice,DWORD dwMsg, DWORD Param1, DWORD Param2, DWORD Param3) {
printf("\nIncomg Line...");
}
help plzzzzzz....
|
|
|
|
|
overloaded Name wrote: This is a small TAPI app which if, I call on my lanfline #, should print something
But?
overloaded Name wrote: printf("\nNumber of lines available to this app: %d",(LPWSTR)num);
This cast looks strange.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hello fellas!
We have a global exception handler "installed" by SetUnhandledExceptionFilter[^] to do some log/dump creating and "gracefully degrade"-ation in case something goes bad. This seems to work quite reliably but...i did some testing by "manually" throwing from inside our code:
throw "stone";
What i don't understand is this: on some systems, this reaches our global handler, creates the dump, displays the "sorry" dialog and shuts down the application, all fine. But on some others, this presents a "CRT runtime error - Abnormal program termination" message box after which is dismissed, the application exits, but our installed global handler doesn't run, so no log/dump is created whatsoever, also, sometimes i see the application "stuck" amongst the processes in task manager.
This particularry seems to happen if i build a release of the project, run it (without debugger), make the exception happen, i get the CRT messagebox, if i copy the same executable to a colegue's PC, run it there, then the global handler gets the exception and works as it should.
So, can anyone explain to me why this happens and how to change it?
I read somewhere that one can also use _set_invalid_parameter_handler[^] to handle CRT exceptions, but the name of this method suggests something else than what i think i am after. Any hints?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
modified on Thursday, September 23, 2010 9:54 AM
|
|
|
|
|
I've had something similar when some other highly clever person in an old team managed to trash the stack. Without the stack there was no way for an exception to find it's way back up to a handler and all sorts of random merriment ensued.
Cheers,
Ash
|
|
|
|
|
I doubt this is the case. The result is always the same CRT-dialog, not random havoc from chaoswille. For testing i started a thread that checks for a certain key-combination and if pressed, throws the exception. There's not much in the call stack that can go wrong (unless somewhere someone corrupts memory maybe but i doubt that) i think.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Are you catching the exception on the thread that throws it? If the exception gets up to the top of your thread's stack and doesn't find a handler you might just find that something in the CRT is throwing an "Abnormal Application Error..."
Cheers,
Ash
PS: Just thought are you setting your exception filter up in every thread?
|
|
|
|
|
As the documentation[^] states: "Enables an application to supersede the top-level exception handler of each thread of a process.", so i don't have to explicitly set this up for every thread, and it seems to be working too (mostly at least).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
I am currently migrating a project from VS 2003 to VS2010 ans trying to eliminate all errors and warnings.
On several functions, I get the warning C4748 (can't protect from local buffer overflow because optimizations are deactivated in this function). The entry on MSDN states that this can happen if either optimization is explicitely disabled via #pragma, or if optimization is automatically disabled because the function contains assembler code.
Neither is the case in none of the functions. But why, then, do I get this warning? And, should I do anything about it, or (#pragma ) ignore?
Here's a greatly simplified piece of code that generates this warning:
class MyBase {
public:
MyBase (){}
};
class MyPt : public MyBase {
public:
double v[3];
};
void sum() {
MyPt p1;
}
Note that removing either the constructor, MyBase(), or the data member, v[3], also removes the warning. Using standard double data members instead of an array also does not produce a warning. I am at a loss.
|
|
|
|
|