|
shanzy1980 wrote:
I change it to the next code block,but I got some error
Why do you want to change it? MFC's CWnd (and derived classes) are wrappers around window handles (those hWnd you see here and there). I can understand that if you obtained an hWnd somehow (e.g.: creating a window yourself using one of the API functions) you may not want to create an MFC CWnd class to wrap it, but if you already have one of the CWnd objects, why would you want to use the API directly instead of using the corresponding class methods?
Anyway... In your code:
BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMyFrameWnd;
::ShowWindow(hWnd,m_nCmdShow);
::UpdateWindow(hWnd);
return TRUE;
}
After m_pMainWnd = new CMyFrameWnd , m_pMainWnd points to a CMyFrameWnd object, but the window won't be still created (unless you added some code to the class constructor to do it).
In ::ShowWindow(hWnd,m_nCmdShow); and the next line, hWnd is undefined.
The translation from CWnd methods to API calls should be like this:
BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMyFrameWnd;
::ShowWindow(m_pMainWnd->m_hWnd, m_nCmdShow);
::UpdateWindow(m_pMainWnd->m_hWnd);
return TRUE;
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
shanzy1980 wrote:
m_pMainWnd = new CMyFrameWnd;
::ShowWindow(hWnd,m_nCmdShow);
::UpdateWindow(hWnd);
In continuation With jose!, here is one more method to achieve same as Mr. Jose stated in his last post!:-
m_pMainWnd = new CMyFrameWnd;
::ShowWindow(m_pMainWnd-><code>GetSafeHwnd()</code>,m_nCmdShow);
::UpdateWindow(m_pMainWnd-><code>GetSafeHwnd()</code>);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
wonderful && excellent! I catch it! Thank you very much!
And Thank you : Christian Graus,Jose Lamas Rios ,ThatsAlok
shanzy
|
|
|
|
|
Hi,
Using Win32_classes I have wrote a code. I have some help from msdn. I am retrieving sound card's info, up to now everything is ok. But also I need to compare "vtProp.bstrVal" with a string like "char c[30]". I think , I should convert this "vtProp.bstrVal" to a string or convert string "vtProp.bstrVal" like variable. Do you have any suggestions?
Thanx...
while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);
if(0 == uReturn)
{
break;
}
VARIANT vtProp;
VariantInit(&vtProp);
c=&(vtProp.bstrVal);
// Get the value of the Name property
hr = pclsObj->Get(L"ProductName", 0, &vtProp, 0, 0);
std::wcout <
|
|
|
|
|
comutils.h contains a string class called _bstr_t. This class will take a bstr and return a char *. So
_bstr_t bt (myChar*);
Now you can cast bt to a char *.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thank you,
But my compiler have not found comutils.h . I am using Visual Studio 6.0, should I install any extension pack?
|
|
|
|
|
I think it's comutil without the s. You should google _bstr_t for full info on it. You may need a platform SDK.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
COM implements two bytes per character method. You have to convert vtProp.bstrVal to a ANSI string.
For that you can use wcstombs() function.
Then you can do the comparision with the ANSI string that you have converted and the actual char[30] string you have.
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Could you give me example about how to use wcstombs()? I have made some try, but not succeded. Thank you
|
|
|
|
|
Hi,
I am using CSocket class to connect between two PC and everything works fine.
However, when the other PC is power cycled, it's IP address is changing and then I'm lost of course.
Is there any way to use the MAC address of the other PC in any class that MFC offers ?
Thanks,
Shay
|
|
|
|
|
The short answer is no - MFC needs the IP address. However, this problem is not new, and there are many pieces of software and services that might be able to help (take a look at DynIP for a starter)
|
|
|
|
|
Thanks for the reply but this may be a bit risky to the end user.
So...
Are all the file swap services and chats like messenger etc. work only via a central server that facilitate the connection ?
Shay
|
|
|
|
|
Yes, they generally all uses some sort of central server. Problem is that you can't use MAC outside your LAN network segment. Outside of this scope even the MAC address is different (see ARP for details). For connecting over tcp/ip or udp/ip you always need a IP address.
You can consider using udp broadcasts in your design - newly started application can send udp broadcast (I'm here and my address is ...) to all interesting parties. But usage of broadcasts are usually limited by the network architecture - usually up to the nearest router.
|
|
|
|
|
The UDP broadcat is a nice concept, but I am connecting to PCs overseas so as you said, it will not go beyond the router.
thanks for the info.
|
|
|
|
|
Hi all,
I'm trying to figure out how to control the size of a CView-derived window during a cascade operation (i.e. when the Cascade menu item in the View menu of a MFC-based MDI app is selected). I've looked into having my CView override various message handlers( WM_WINDOWPOSCHANGING, WM_GETMINMAXINFO, WM_NCCALCSIZE, and WM_WINDOWPOSCHANGED), but none of those messages seem to contain enough information for my CView to know whether it is being cascaded, or just resized in another way( maximized, restored, resized by the user, etc.).
Do I need to look into overriding the way an MFC app handles the Cascade command, and if so where would I start on that?
Any advice or suggestions greatly appreciated.
Cheers,
Pete
|
|
|
|
|
Hello
Can someone help me with some code.
I'm try to get some info from a ini file and get it in a variable
|
|
|
|
|
|
|
I am a little fuzzy on this concept of subclassing. I have derived my own control (derived from CEdit). I am able to utilize all of the messages common to CEdit doing this. I have seen other examples of code where the function SubClassWindow (not necessarily with a CEdit) is used by itself and also in addition to a derived class. What's the difference? When should one be used with/instead of the other. Seems both methods are doing the same thing.
|
|
|
|
|
Hello...
mx483 wrote:
What's the difference?
Nothing... In front of the subclassing concept...
It's only a difference of the design concept...
I believe you have read two different solutions of subclassing, the first "used by itself" in the good old c style without inhertance and the other one in c++ with oo aspects...
Best regards...
|
|
|
|
|
There is one "subclassing" meaning in the usual class derivation: if class A derives from B, then A is a subclass of B.
The meaning of "sublassing" in methods like SubclassWindow is different. It refers to the act of changing the function that processes the messages directed to a given window (its window proc) to the one you want.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
I believe those messages are being captured when you derive a class from another class. So would the real difference be that using the derivation method you are able to add your own functions and implementation rather than just capture messages using the SubClassWindow function?
|
|
|
|
|
Hi,
I'm trying to write a control that contains lots of child controls, and allows you to scroll them up and down. This would be very much like how CFormView works, except based on CWnd, not on CView. Can anyone give me a rough outline of the mechanism which CScrollView uses to draw the child controls at different locations as you pan around without moving those child windows?
Joel Holdsworth
|
|
|
|
|
|
Thanks man. That's a massive help!
Joel Holdsworth
|
|
|
|