|
Hi,
I've made a class which inherits CEdit. I want to set up some styles for the class, so what i've tried is handling WM_CREATE.
However, it seems that CMyEditClass::OnCreate is not called when the implementation uses a dialog box control id and classwizard to bind them together.
But, if I do this:
CMyEditClass my_edit;
my_edit.Create(....);
in this case OnCreate is called. So, i've proved to myself that Edit controls in dialogs are not "Create"d. What message can I handle that is common to both methods of using the class, that is suitable for modifying styles and so on? I'd use Spy++ but I don't know how to make it catch messages send to the window when the window is only just being created.
Thanks for your help. I hope I've explained it right
J
|
|
|
|
|
So, i've proved to myself that Edit controls in dialogs are not "Create"d.
They are created, but creation occurs before MFC stuff is hooked to dialog. Override CWnd::PreSubclassWindow to avoid this problem. And remember that you can't change some ES_xxx styles at runtime.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello
In my appp i need a combo box wich will show me available drives on the computer and a list control wich will show the files and the folders.
my quastion is: i know how to extract assosiated icon for the files, but how do i do that for the drives and for the folders?
what is the best way to this?
thanks.
|
|
|
|
|
how do i do that for the drives and for the folders?
SHGetFileInfo() can get the icon for a drive/folder. Check out A Drive Picker List Control for some sample code.
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
|
Perhaps you should RTFM about SHGetFileInfo() ?
|
|
|
|
|
|
You don't want to know this
RTFM stand for: Read The F***ing Manual.
Cheers,
EiSl
|
|
|
|
|
Hi,
I've created a MDI project with the Doc/View architecture (which I don't
use, but it has advantages).
As you will know, CMainFrame initialises the standard docking toolbar. But I
wanted another one, that contains dynamically updated buttons depending on
the MDIChildWindow that is active.
So I've got two questions:
1. How does the CMDIFrameWnd get message if a new child window has been
created by CDocTemplate::OpenDocumentFile(NULL), and
2. how can I create a second, docking toolbar in the Mainframe
Thanks in advance, Karl
|
|
|
|
|
How does the CMDIFrameWnd get message if a new child window has been created by CDocTemplate::OpenDocumentFile(NULL)
Check CWnd::OnMdiActivate.
2. how can I create a second, docking toolbar in the Mainframe
Just like the first one. Add a CToolBar member to CMainFrame class and call CToolBar::Create and CToolBar::LoadToolBar. Have a look at CMainFrame::OnCreate for details.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
How do I get a popup menu in my dc that looks like a pane
Handle WM_CONTEXTMENU in your window class. Device context has nothing to do with this.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi, I'm a begginer in C++ (started learning 3 months ago) and I have a problem when using strings.
I don't know why but sometimes, I declare two strings (stringA and stringB of type _bstr_t) then I use them assigning stringA to a value and when later, I assign to stringB any value it changes also stringA's value.
It doesn't happen always and I'd really like if somebody could help me with that.
|
|
|
|
|
It depends on how you are assigning. Check that the two aren't using the same memory address.
Gerry.
|
|
|
|
|
But there is something I still don't understand about C++: How can both strings use the same memory address if I'm not using any pointer on them?
The exact situation is that I've a class with a public member variable of type string (_bstr_t) and a method for that class where I receive a _bstr_t parameter (not a pointer).
If I call this method without the parameter everything goes right, but if I call it with the parameter, the public member variable gets its value changed with the parameter's one.
Thanks for answering,
|
|
|
|
|
It doesn't happen always and I'd really like if somebody could help me with that.
Post your code. How can you expect anybody to answer your question without source?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
O.K here's the code
First I've a class with a public member variable:
BSTR stringA;
then from a function I write:
MyClass *ptrMyClass;
MyClass->stringA = _bstr_t("SomethingA");
_bstr_t stringB;
stringB = "SomethingB";
After that, MyClass->stringA contains "SomethingB" although I've noticed that it only happens if SomethingB.length>128
Please, tell me what I'm doing wrong (and most important why)
Thanks for everything,
|
|
|
|
|
MyClass *ptrMyClass;
MyClass->stringA = _bstr_t("SomethingA");
You're using uninitialized variable ptrMyClass. You know how pointers work, don't you?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
BSTR is defined as wchar_t * and thus is really a pointer. You should also uses _bstr_t type for your class member as that class is a wrapper for BSTR and will handle copy and similar things properly.
The reason why the string would be reused is that the pointer (stringA member) is initialized (incorrectly) from an implicit conversion operator of class _bstr_t. Since _bstr_t("SomethingA") create a temporary object which will last only for the expression, the memory allocated by the (temporary) object will freed before the next instruction and will be available for subsequent allocation.
So Windows may reuse the same address for that subsequent allocation and this is why the first string (stringA member) may now have that value. In any case, as mentionned in another answer, stringA member is not properly initilized...
If you want to uses BSTR for the class member, then it should be initilized using SysAllocString and it should then be freed by the class destructor using SysFreeString.
Philippe
|
|
|
|
|
Thanks for everything, at last I've understood it!
|
|
|
|
|
I want take ownership of a file from a process running as administrator, but the administrator dont have any permit in the file.
I can do this from the explorer (file property, security, advanced, owner) but with win32 security API i cant do it. With SetSecurityInfo or SetNamedSecurityInfo the result is error because i dont have permits. If i can do it from windows explorer, why not from security API?
thanks in advance
Mario
|
|
|
|
|
Hi all,
How can i change the title bar in SDI mode ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
|
Hi,
I used of SetWindowText in WM_ACTIVATE and WM_CREATE messages ... but don't work !!!
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
If SetWindowText doesn't work for you, you'll need to override CFrameWnd::OnUpdateFrameTitle.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi All,
I have Overridden the CwinApp::Run function in my code and I have called
some of the functions which does my desired work.There is no problem with
these functions as they execute properly. But when the control tries come
out of the CwinApp::Run function it enters the MFC code and crashes there.
The main problem is in the File "WinHand.cpp" (Within Visual Studio). In
that file the following function gives the problem.
void CHandleMap::DeleteTemp()
{
if (this == NULL)
return;
POSITION pos = m_temporaryMap.GetStartPosition();
while (pos != NULL)
{
HANDLE h; // just used for asserts
CObject* pTemp;
m_temporaryMap.GetNextAssoc(pos, (LPVOID&)h, (void*&)pTemp);
// zero out the handles
ASSERT(m_nHandles == 1 || m_nHandles == 2);
HANDLE* ph = (HANDLE*)((BYTE*)pTemp + m_nOffset); // after CObject
ASSERT(ph[0] == h || ph[0] == NULL);
ph[0] = NULL;
if (m_nHandles == 2)
{
ASSERT(ph[1] == h || ph[1] == NULL);
ph[1] = NULL;
}
delete pTemp; // virtual destructor does the right thing
}
m_temporaryMap.RemoveAll(); // free up dictionary links etc
}
In the above function there is a line which says ASSERT(ph[0] == h || ph[0]
== NULL);
It is crashing at this particular. I am not able to understand why exactly
it is giving this problem.
Does anyone have any idea about the problem. Any help is hugely appreciated.
TIA
Srinidhi.
|
|
|
|