|
Sorry if this is a simple question, but I can I get the handle to a window given the IDD resource value.
Here is what I want to do
CMainFrame (dlg1, dlg2, dlg3 created)
CMainFrame::ShowDialog(int nID) // Will display the dialog for IDD value
dlg1
OnOK() calls ShowDialog(IDD_DLG2) like this
((CMainFrame*)m_parent)->ShowDialog(IDD_DLG2)
I want something like:
CMainFrame::ShowDialog(int nID)
{
CWnd *pWnd;
pWnd = (CWnd *) GetDlgItem(nID); // Or 'GetWindowHandle(nID)'
if (pWnd->IsWindowVisible() )
pWnd->SetFocus();
else
pWnd->ShowWindow(SW_SHOW);
}
Is there a member function that can return a window handle give an IDD resource value?
Thank you.
Johnny
|
|
|
|
|
john john mackey wrote:
Is there a member function that can return a window handle give an IDD resource value?
No, this is not possible. A dialog resource (which is represented by an resource ID) is just a template for a dialog layout. It does not represent an actual dialog instance, which is represented by a hWnd.
Think of a dialog template as of a class in OOP. You can create an arbitrary number of dialog instances of the same dialog template. Therefore an one-to-one mapping between IDD and a hWnd could not even exist.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
|
|
|
Also Layout | Tab Order.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hello all.
I've run in a problem when trying to get back the return value from a batch file called from a C program (Windows NT) . Here is the code :
/* C code */
#include <stdio.h>
#include <stdlib.h>
void main()
{
char* message[1024];
int ret = 0;
sprintf(message, "%s /C %s", getenv("COMSPEC"), "c:\\test.bat");
ret = system(message);
printf("%d\n", ret);
}
/* end C code*/
/* Batch file (c:\test.bat) */
exit 7777
/* End batch file*/
Now, I was expecting that "ret" has the value of 7777 but it seems that 0 it's all what it returns.
I was looking in the help of EXIT command and I found there that an exit code can be set :
EXIT [/B] [exitCode]
However this seems not to work.
I can return a value from a VB Script using Wscript.Quit 0 or from an Unix script but not from a batch file.
Any ideea regarding this issue ?
TIA.
|
|
|
|
|
|
the list control must know the string to put in the list control, if you need to put an integer or a double, etc. then you should format it first.
i show alot of integers in some of my lists, so i wrote a simple int to string function.. something like:
CString CCommonFunctions::toString(int nVal)
{
CString strTemp;
strTemp.Format("%i", nVal);
return strTemp;
} that way when you add your value to the list control you can just use
m_lstMyList.InsertItem(0, CCommonFunctions::toString(nMyInt));
also remember you can set a pointer to each object incase you need to associate each item with a custom object
CMyObject* myObj = new CMyObject("blah",1,20);
m_lstMyList.InsertItem(nPos, CCommonFunctions::toString(myObj->m_nX));
m_lstMyList.SetItemData(nPos, (DWORD) myObj); then later use GetItemData()
CMyObject* myObj = NULL;
int nPos = m_lstMyList.GetSelectionMark();
if (nPos != -1)
{
myObj = m_lstMyList.GetItemData(nPos);
}
-dz
|
|
|
|
|
didnt see you were asking about doubles specifically.. something like this:
CString strDouble;
strDouble.Format("%f", dDouble);
m_lstMyList.InsertItem(0, strDouble.Left(4)); <code>
-dz
|
|
|
|
|
Hi everyone,
Where can I find a good tutorial on creating ActiveX controls using C++. With and without MFC (though, I guess that would be like pulling your own teeth). Also, any book recommendations would be great too!
Thanks,
Pankaj
//=================================================
Q: How many C++ programmers does it take to change a light bulb?
A: You're still thinking procedurally. A properly designed light bulb object would inherit a change method from a generic light bulb class, so all you'd have to do is send a light-bulb-change message.
|
|
|
|
|
pankajdaga wrote:
Q: How many C++ programmers does it take to change a light bulb?
None! Its a hardware problem....
Err, sorry I can't answer yout real question.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
When you have a member variable of type _Recordset, and first create it you do a createinstance. Now if later in the code, you do it again, like
HRESULT hr = m_pRecordset.CreateInstance (__uuidof (Recordset));
then in essence have you overwritten the object, as in deleted the old recordset and created a new one addressed by the same variable pRecordset?
Basically I want to clear out the contents of the variable (the old recordset )and fill it with the results of my new search. I dont know if this is obvious, but I am none too sure.
Thanks,
ns
|
|
|
|
|
Hmmmm. I will try and be simple here. CreateInstance is like new(). What it does is what it says. It creates an instance of the recordset object.
If you wish to refresh the contents of the recordset with new data then simply close the recordset and open it with a new sql. There are probably other ways too. But do not call CreateInstance again. That is not the right way to do it.
Calling CreateInstance again is not equivalent to deleting.
You can read up on CreateInstance on MSDN or in any COM book.
|
|
|
|
|
It worked to just close the recordset and reopen with a new command. I think if you dont close it and try to open it again with a different command, it bombs. I was looking for something like rs.clear() and .close() escaped me. I thank you very much!
ns
|
|
|
|
|
Hi, I'm learning DirectDraw. I have a problem:
I've created two surfaces using a COMPLEX surface, because I want to do some flipping. I'm using FULLSCREEN | EXCLUSIVE | NOWINDOWCHANGES mode.
The flipping occurs, but for split second, every once in a while, I see the desktop and everything on it. A flicker, if you wish to call it that...
The mouse cursor is always visible during my animation, although I'm in full screen. And the cursor seems to be "aware" of what's going on "behind" my application:
It changes its shape according to messages of other windows, and if I try to "drag" somewhere on my fullscreen application, it activates the window behind it (let's say, Microsoft Word) and starts highlighting text!!!
I've tried maximizing my MFC window before entering fullscreen. It doesn't help, since my own application window still responds, and I can see it when a flicker occurs.... The taskbar is also responding (I see it flickering when I move the cursor over it).
How do I REALLY get exclusive access to the display???????
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
I have a program that uses CArray <ccode, ccode=""> m_IL;
Everything compiles @ level 4
when I try to use .Add(code) - the CArray asserts with Assert valid , invalid vtable . Why ??????
Could someone please help!!!!!!
viva AMIGA
|
|
|
|
|
If you have declared it as CArray m_IL, then that's wrong. It is a template, you have to use it as e.g.:
CArray <type, type="" &=""> m_IL;
Otherwise, post your code here.
Martin
--------------------------------------------
C'mon we all know computers are experimental devices and should only be used for playing games.
Using them for alternative stuff like business, is clearly not using them for what they are intended.
Colin Davies
|
|
|
|
|
it is defined as CArray <ccode ,="" ccode=""> m_IL
viva AMIGA
|
|
|
|
|
Ahhh the html is picking up the <> its
CArray <CCode,CCode> m_IL
viva AMIGA
|
|
|
|
|
I've just found this function but I'm having a problem getting a response from the ftp server. Parameter 2 in the documentation says it should be set as
CmdResponseType eResponse = CmdRespRead
to get a response back from the server, but anyway I try to change it to this it won't compile because it doesn't recognise what CmdResponseType is or it doesn't recognise CmdRespRead.
Has anyone had experience of how to get around this? Thanks for listening again
ps, the function is this one that I'm trying to use. Thanks
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/vclrfCFtpConnectionCommand.asp
|
|
|
|
|
Sorry, forgot to mention that I'm using VS.Net to make this, so its that version of MFC thats being used.
So far all I've discovered that the CmdResponseType is defined as an enum in the afxinet.h file, but I can't for the life of me make any use of it at all
Thanks for any help I may get
|
|
|
|
|
Hi... I have a problem.
How to get the scrollbar of a CListCtrl and change its background color ?
|
|
|
|
|
Hi:
When my application start, it allocated some memory from private heap and freed them later,but windows didn't collect them.Windows report that those memory blocks were in use.So, yy question is:
How to : let system collect the memory that has already been freed by application
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
you can try _heapmin
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|