|
I believe it was just yesterday that Blake Miller correctly suggested using a non-dialog approach. Just use a pop-up child window.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I want to try working with Dialog first(plus I want to learn how to use Dialog). If I really can't do it then I will switch over
|
|
|
|
|
Can this function call fail in some configuration of Windows NT 4.0 and later? The docs state that the complementary SetSystemTime call will fail if the user doesn't have the privileges to set the time on a system. I have an application that is failing to return this information. The function is void, so the only real valid check is to check the SYSTEMTIME struct for empty values.
|
|
|
|
|
It is very hard to believe that GetSystemTime() could fail and I certainly have never seen it. MSDN and Googling don't show anything like this.
It could be worth testing GetLastError() even though doc's don't mention it is relevant. Also try GetLocalTime() and time(NULL).
Maybe your code is clobbering the SYSTEMTIME struct. Are you checking it directly after the call to GetSystemTime() or later on?
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Are you passing the SYSTEMTIME structure in correctly?
The structure has to be an [out] parameter. So you need to call the API with the pointer to the structure.
This will NOT work:
////////////////////////////////////////
//Declare a SYSTEMTIME structure
SYSTEMTIME stSystemTime;
//Call GetSystemTime
GetSystemTime(stSystemTime);
////////////////////////////////////////
Instead you should call something like this:
////////////////////////////////////////
//Declare a SYSTEMTIME structure
SYSTEMTIME stSystemTime;
//Call GetSystemTime
GetSystemTime(&stSystemTime);
////////////////////////////////////////
Good Luck,
Robert
|
|
|
|
|
Please could someone help me with the Net API :
What I need my application to do is allow the user to type in their username, password and Domain and then using the Net API validate the password with the username and then see if the user is a member of a certain group (A group which I have set up).
Could anyone help me on this subject (Really struggling).
Any sample code (Using C++ MFC/win32) or guide lines would be very much appreciated.
For ever grateful
Regards
Richard
P.S. Thank you for your time!!!! =
|
|
|
|
|
Does LogonUserEx() help?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
If I create a function in an MFC app that does not reference the class, how can I get it to see any pointers that I have in this function
any point that is placed in this function works:
<br />
void CMyThread::OnClose()<br />
{<br />
<br />
}<br />
any point or variable referecnes in this function will not work
<br />
void OnClose()<br />
{<br />
<br />
}<br />
I know it won't because I'm not referencing my class any more. So how can I get it to work with out referencing my class?
God i hope this make sense
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
If you want the OnClose() function that is not a member of CMyThread to be able to access CMyThread 's member variables, those variables would need to be static .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have another program that has this code snippet in it:
<br />
__declspec(dllexport)int LA_OnSend(char* EmailAddress, char* EmailMessage) <br />
{<br />
AFX_MANAGE_STATE(AfxGetStaticModuleState());<br />
<br />
CLASendMailApp* sendmail = (CLASendMailApp* )AfxGetApp();<br />
if (!sendmail->LoadSettings())<br />
{<br />
Can you tell me what this is doing here?
CLASendMailApp* sendmail = (CLASendMailApp* )AfxGetApp();
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
AfxGetApp returns a pointer to a CWinApp object.
(CLASendMailApp* )AfxGetApp() casts that pointer to a pointer to a CLASendMailApp. that way, any functions called through that pointer will act on your CLASendMailApp application, and not on the CWinApp base class.
why ? CWinApp doesn't have a LoadSettings() member function. CLASendMailApp (hopefully) does.
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
Okay so if I need to access a function that is in another class that I have I can "cast" it like this? Can I cast down to a certain function in my class?
And in my first example can I cast a pointer to me class in the
void OnClose function?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
I need to access a function that is in another class that I have I can "cast" it like this?
you can only safely cast a pointer like this if the To and From class are realted to each other (ie. if the To class is derived from the From class, or vice versa).
Tom Wright wrote:
And in my first example can I cast a pointer to me class in the void OnClose function?
you can't cast a class pointer to something that isn't a class. if you need pointers to your class in a function that isn't a member of your class, you'll need to pass a pointer to an object of your class into that function (or maybe make it available as a global variable):
void CMyClass::someFunc()
{
NonMemberFunc(this);
}
void NonMemberFunc(CMyClass *pMyClassPtr)
{
pMyClassPtr->someFunc();
}
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
So Chris is it possible to redefine a function such as:
<br />
static void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)<br />
To include CMyClass *pMyClassPtr, so that I would have access to all the objects in CMyClass?
<br />
static void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)<br />
{<br />
if (idEvent == 1)<br />
{<br />
KillTimer (NULL,idEvent);<br />
CString mySelect;<br />
mySelect.Format("UPDATE EMG3 SET EMG3_STATUS_DATE = CURRENT_TIMESTAMP WHERE EMG3_DEST_ID = '%s'", thdID);<br />
m_pConnection->Execute(_bstr_t(mySelect),NULL, NULL);<br />
SetTimer(NULL,1,m_nHearbeat*1000,NULL);<br />
}<br />
That way i can access thdID and m_pConnection. Is this right?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
To include CMyClass *pMyClassPtr, so that I would have access to all the objects in CMyClass?
i think you'd have to make those variables global, for that function to be able to use them.
maybe if you could expand on what you're trying to accomplish, i could give better answers. just pointing out C/C++ syntax errors probably doesn't help you much.
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
I'm trying to setup a Timer in my UI thread. While doing this I found that the easiest way was to do the SetTimer with the forth parameter being the callback function.
Problem is that I've never really worked with callback function and while working with this particular one I found that i did not have access to m_pconnection pointer and the thdID pointer.
I remembered that someone had helped me with another program that did a casting of a pointer like the one listed at the beginning of the post, but i wasn't sure if this is what I needed to do here and since i didn't really understand what was happening with that line of code I decided to post.
So comming full circle I'm still trying to understand when one needs to cast a pointer and when one needs to pass a pointer.
Heck I just found out how to initialize a char array on the fly (so to speak) using the new operator. I've always seen it used but never understood why until it was explained to me.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
I'm trying to setup a Timer in my UI thread. While doing this I found that the easiest way was to do the SetTimer with the forth parameter being the callback function.
if you're doing this in an MFC app, you can just use the OnTimer function to handle this: use the class wizard, if you're using VC6, or change the window/dialog/app properties in VC7, to add a handler for WM_TIMER. that way, the function will be a member of your CWnd and you can use any class functions you want.
the problem with the callback method, in my opinion, is that it doesn't give you a way to pass any custom info into the callback function. some callbacks give you a parameter that you can use for things like pointers. this one requires you to get all the data from global variables.
Tom Wright wrote:
So comming full circle I'm still trying to understand when one needs to cast a pointer and when one needs to pass a pointer.
you pass a pointer when you need a pointer to something.
you cast a pointer when the pointer doesn't point to what you need it to point to, but can safely interpreted as if it was pointing to what you need. for example, if you have a pointer to an object of type C, you can cast that pointer to anything that C is derived from; this lets you call functions from the base classes; ex. if class C is derived from class B, you can cast your C* pointer to B* and then call class B's functions. likewise, if you have a C* pointer (a pointer to an object of type C), and you've cast it to a base class of type "B" ( B* pB = (B*)pC; ), you can cast that back up to a "C". but, all this requires that you know what the pointer is really pointing to, and what the class heirarchy looks like.
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
It is casting the return value of AfxGetApp() from a CWinApp* to a CLASendMailApp* so that the LoadSettings() method can be accessed.
In the past, I've always added this to my app's .h file right below the class declaration so that I did not have so many of those casts staring at me:
#define GetSendMailApp() (((CLASendMailApp*)AfxGetApp())) Then to use it:
CLASendMailApp* sendmail = GetSendMailApp();
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
David if I were to look this up in the MSDN would it be pointer casting or just casting?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
if I were to look this up in the MSDN...
Like this?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
no more like the stuff you mentioned earlier. Casting pointers. I just wanted to read more about it.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
In an MFC MDI app, I need to determine the ordering of open documents, based on the z-order of the associated views. I tried using GetFirstDocPosition() and it's associates, but it turns out that only gives me the order in which the documents were opened (which is the same as the order typically displayed in the "Window" menu). What I need though is the order in which the documents are in the z-order (like if you cycle through them with CTRL-TAB).
I know this is possible, the VC.NET 2003 IDE shows the "Window" menu in this order, I just can't figure out how it's done.
Any ideas or directions I can look?
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
You'll need to enumerate the MDI child windows. Have a look at GetWindow( GW_HWNDFIRST / GW_HWNDNEXT ) and GetNextWindow() and also EnumChildWindows ().
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
That looks like exactly what I was looking for.
Thanks a bunch!
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
int a,b,c,d;
a= (m_num1+7)%10;
b= (m_num2+7)%10;
c= (m_num3+7)%10;
d= (m_num4+7)%10;
m_enum1=a;
m_enum2=b;
m_enum3=c;
m_enum4=d;
here is the code i used to get the modulus the problem is the when the value of m_num1 is 1,2,3,4 it produces the answer 8,9,0,1 respectively.
|
|
|
|