|
eg.
HRGN
Here is the code in MFC, does it make sense?
this can't be NULL when the non-static member function is called, can it?
_AFXWIN_INLINE HGDIOBJ CGdiObject::GetSafeHandle() const
{ return this == NULL ? NULL : m_hObject; }
logics
|
|
|
|
|
followait wrote: this can't be NULL when the non-static member function is called, can it?
Certainly it can:
Object *ptr = NULL;
ptr->Method(); Remember, the this pointer is simply an implicit argument to a non-static member function. It's as if this:
class Object {
void Function(int arg1, int arg2);
};
void Object::Function(int arg1,int arg2)
{
} was implemented as
void Object_Function(Object *this,int arg1,int arg2)
{
};
|
|
|
|
|
There's no dereferencing involved when calling a non-virtual method. All that happens is the pointer value is passed to the method, and becomes the value of this .
|
|
|
|
|
Hi,
I have Dos Console process which has a lot of data which I want to
Display in WIN32 GUI
So I did a CreateProcess to create the WIN32 app exported the structure unfortunatlly the data in the DLL exported structure seems to be lost
Hmm. seems that even though the address of DLL is the same in both the Dos Console and the WIN32 app
The data must be shared.....
from research is seems that along with exporting this structure
I have to put it in the shared data segment
a #pragma data_seg(".SHARED") and #pragma data_seg() must be wrapped around structure in additon to telling the linker via #pragma
that this is Read / Write section via
#pragma comment(linker, "/section:.SHARED,RWS)
One caveat to all this is that the variables must be initialized
There a lot of memebers in this structure to initialize
but alas if there is no other way
I been reading about Mapped Memory files
all suggestion are welcome
thankx
|
|
|
|
|
hello everybody!
now I want to draw something on the flash control background
I have already realized the ole container of flash control,
in the WM_PAINT message handle function,
I call OleDraw to Draw the content of Flash at first
after that, I Draw sth on the HDC,
But I found that some event of flash will redraw itself,
so, the content that I draw is always covered by the content of flash control
I want to draw sth. on the flash control background
reference url: http://www.codeproject.com/KB/COM/flashcontrol.aspx
I found that the IAdviseSink interface
hr = m_lpO->QueryInterface(IID_IViewObjectEx, (void **)&m_lpViewObjectEx);
after that,
if(S_OK == pview->SetAdvise(DVASPECT_CONTENT, 0, (IAdviseSink*)this) )
{
TRACE("S_OK");
}
the debug window display "S_OK"
the "this" pointer is
class COleContainerWnd : virtual public IOleClientSite,
virtual public IOleInPlaceSiteWindowless,
virtual public IOleInPlaceFrame,
virtual public IStorage,
virtual public IAdviseSink
but can't catch IAdviseSink::OnDataChange() and IAdviseSink::OnViewChange() Event
why? -_-!!!!!!
Now the question is
How to catch the redraw event of Flash control,
and add some extra code in the redraw handle function of flash control
Sincerely
|
|
|
|
|
I have an application which has a Dialog and a Tab control, each tab is a PropertyPage.
I don't have a Oninit handler for my Propertypages.
The situation I ran into is because I had to create a menu in the main dialog.
I have a Edit control and CComboBox in my Property page PPOne.
In my file menu, I do File Open, through which I can open a file and read its contents, am able to populate memory,then I perform the step m_oPPOne.Create(IDD_PP_ONE)(this is from a class derived from Ctabctrl) I see the tab appear, now how can I make the the data for the controls on this PP appear in their fields ?.
Example: Normally when I am on the PP if I click a button, this below function works fine.
Void CPPOne::OnBtnRefreshClicked
{
CString str;
str.Format("%d",some_int1);
cs_my_edit_control = str;
UpdateData(TRUE);
ccb_my_combo_box.SelectString(0,*(&my_predef_Str[0+some_int2]));
}
But if I call this above function from my main dialog, it fails on the UpdateData line with a assertion failure in line 4184 of wincore.cpp saying doing UpdateData before DoModal.
How can I overcome this? any suggestion would help.
Best Regards
RV
|
|
|
|
|
What is the difference among the OnClose(),OnDestroy() and the DestroyWindow()?
The other question:When you want to close a window,you can click the button "X" on the upper-right of the window.In the windows messages,what messaget dose his action invoke,WM_CLOSE,WM_DESTROY or other messages?
|
|
|
|
|
Have you considered using the debugger to put a breakpoint in each of those message handlers to see what happens?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Yes, I have done it.When I put a breakpoint in the OnClose() and OnDestroy(),I close the windows,both is equvalent.
Do you have the more wonderful method?
|
|
|
|
|
WM_DESTROY is sent as a result of calling DestroyWindow.
WM_CLOSE is sent to you to close the window. but you may close it or not. it's just a request. you can accept the request by calling the parent class's OnClose().
WM_DESTROY is sent when the window is about to be destroyed even if you don't like to close it. It will be closed anyway and then the class destructor will be called.
|
|
|
|
|
WM_CLOSE is sent when you click the close button (or hit Alt+F4 or close the window some other way). Normally, you would do some cleanup and then call DestroyWindow() . If you let DefWindowProc handle WM_CLOSE , it will call DestroyWindow() for you. WM_DESTROY notifies you that the window is being destroyed.
|
|
|
|
|
Im new in C++. I want to read a text file in my Win32 Console Application of C++.net 2005, how can i do it? Kindly tell me in .net 2005 unmanaged code plz.
nOmI
|
|
|
|
|
Check out CreateFile() and <codereadfile()>. C++ also has stream classes like ifstream .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I dont see this[^] article but I think it has some helpful info for you.
|
|
|
|
|
Hi
We know that Windows keeps a message queue for every thread.
If i am not wrong for win32 applications, only one message loop is enough.
But in MFC applications, we have Message Map macros(DECLARE_MESSAGE_MAP/BEGIN_MESSAGE_MAP/END_MESSAGE_MAP) for every window class. Mainfrm, chidfrm, childview, doc etc..
Do all of the message map macros that we see in the source code indicate there is a message loop that buried in MFC source code?
I couldn't make relation between win32 message handling and MFC message handling.
Thanks...
|
|
|
|
|
sawerr wrote: We know that Windows keeps a message queue for every thread.
Only if you call a function that causes a queue to be created on a thread.
sawerr wrote: for win32 applications, only one message loop is enough.
Yes, one is sufficient, but not necessary unless you create at least one window.
For example, you don't need a message loop in a console app.
sawerr wrote: Do all of the message map macros that we see in the source code indicate there is a message loop that buried in MFC source code?
Yes, but not a separate message loop for each window/class.
There's still one per UI thread. See the source code for
CWinThread::Run() - the per-thread message loop is there.
The CWinApp class derives from CWinThread, so for an MFC GUI app,
your required CWinApp object generally provides the first/main
message loop.
Once messages are extracted from the queue in a message loop, then
they are dispatched to their destination window via a call to the destination
window's windowproc (window procedure). That's basic Windows windowing[^].
The message map table macros generate compiled code that maps a message
received in the windowproc to a call to the appropriate window class method.
Hope that makes a little sense.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
For example if we want to use Edit control in win32 app, the code will be:
hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
0, 0, 100, 100, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
Here we create a "control". That control has a message loop in its source code which was written by controls developer. If an event happens, it is sent to its module(for example user32.dll) not to our application. It sends to our program a notification.
OK.
But in MFC, We use CEditView which is derived from CView. So we create a new window.
And CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",...) is in the CEditView.
Has that view window got a message loop too?
If no, how can we handle for example WM_CLOSE
void CTextView::OnClose()
{
CEditView::OnClose();
}
You said:
Mark Salsbery wrote: The CWinApp class derives from CWinThread, so for an MFC GUI app,
your required CWinApp object generally provides the first/main
message loop
If view window has a message loop, is that mean it is created by a new thread?
For example, When user close this CeditView window, is this message sent to Main Window or View Window?
If it is sent to main window, does main window route it to view window?
I'm sorry, i really don't solve/understand the mechanism...
Thank you.
|
|
|
|
|
sawerr wrote: Here we create a "control". That control has a message loop in its source code which was written by controls developer.
No, it doesn't. It has a window procedure implemented by the control developer.
You are still responsible for providing a message loop.
You're confusing message loops with window procedures.
Window procs are related to the window class. MFC subclasses windows so
the MFC framework gets first peek at messages before forwarding unhandled
(i.e. no message map entry) messages to the original window proc.
sawerr wrote: If view window has a message loop, is that mean it is created by a new thread?
That doesn't make sense. Windows don't have message loops.
Threads can implement a message loop. Windows have window procedures,
which are functions called by the system to send a window a message.
Study the link I gave you on windowing. It's the fundamentals
of Windows programming, and in my opinion, essential to know and
understand completely to be an effective Windows programmer.
If you need more drawn-out documentation on how it all works, then I
recommend the book "Windows Programming" by Charles Petzold.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: You're confusing message loops with window procedures.
Yes, that's right. And now i understand.
-One loop
-Get Message and
-DispatchMessage finds the right window procedure.
Thank you for help...
|
|
|
|
|
I'm trying to access my eMail contents using a POP3 client app I'm trying to design (something like a simple command line). My eMail Address is testpopid@yahoo.com (I've made it temprarily and will delete it after your answers ). here is my conversation with the server:
telnet pop.mail.yahoo.com 110
<br />
+OK hello from popgate 2.4 ...<br />
USER testpopid<br />
+OK Password required.<br />
PASS MyPassword<br />
-ERR [AUTH] invalid user/password
where "telnet" connects to a server (in this case "pop.mail.yahoo.com") and '110' is the port number used to connect to server.
I use the password I defined when creating the eMail account. When I try to log into my account within my brower, ther's no problem and the above password works (I use www.yahoo.com to log in)
Thank you masters!
|
|
|
|
|
How are you passing your password? Plaintext? I'm not familiar with how yahoo will handle doing logins, but perhaps the password doesn't go in as plaintext?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I'm pretty sure yahoo only allows POP3 access if you're using a paid account.
If I'm right, then yahoo is waiting to verify who you are, looking you up, and rejecting you [*].
Iain.
[*] Don't take it personally.
|
|
|
|
|
I'd like to read a wav file, not using playsound() function. I want to get the wave of the sound and draw them out. Which function can solve this problem? Please give me some tips.
|
|
|
|
|
As cool as your name.
BTW, it may be easy for UNIX, coz everything in UNIX is a file.
logics
|
|
|
|
|
No UNIX Please
Thank you masters!
|
|
|
|
|