|
Try something like:
typedef void (*FN_MyCallback)(void* pParam1, void* pParam2);
void somefunction(FN_MyCallback pfnCallback, void* pParam1)
{
// Do stuff...
// Callback
(*pfnCallback)(pParam1, pParam2);
// Do more stuff...
}
Dialog
void CMyDialogAppDlg::OnCallTheLegacyStuff()
{
somefunction( &CMyDialogAppDlg::LegacyCallbackStatic, (void*)this );
}
void CMyDialogAppDlg::LegacyCallbackStatic(void* pParam1, void* pParam2) // Must be static member
{
((CMyDialogAppDlg*)pParam1)->LegacyCallback( pParam2 );
}
void CMyDialogAppDlg::LegacyCallback(void* pParam)
{
// Update the display...
}
Dave
|
|
|
|
|
|
I am using a CTabCtrl, and two CListCtrl's underneath. I used the dailog editor to add them to a dialog (the tab order has the CTabCtrl as being the first item). When the dialog is initialized, I use ShowWindow() to show the appropriate list control, and hide the other. The same is done when you click on the tab control.
Everything works fine until you do one of a few things:
1. Simply re-size one of the list control's columns until a scroll bar is required.
2. Minimize, and restore the window.
Either one of these will create a redrawing problem that looks really bad. If I click on the tab control, it will clear up.
Is there something I can do to clear this up? Has anyone seen this before? I saw an article posted on another web site that describes a similar problem, but the answers were numerous and not very helpful.
Thanks,
David
|
|
|
|
|
Can't be sure, but here's a couple of things to try:
1) check the z-order of the controls on your dialog. Both list controls should be higher (later in the tab order) than the tab control.
2) if #1 fails to resolve your problem, you can set the WS_CLIPSIBLINGS style on the tab control (using ModifyStyle() for instance).
---
Shog9
This is my December
These are my snow covered dreams
This is me pretending
This is all I need...
|
|
|
|
|
I have two problems with the position of the toolbars. In my applicaton I use more than one toolbar. All toolbars are moveable and dockbale and the positions are saved in an external file. The problems are:
1. If I change the size of my parent window in the way that it is very small all my toolbars are on the left side of my application and among each other.
2. Sometimes my toolbars change their positions but I don't know under which circumstances. This happens only if I end my application or if the size of the parent window is changed. It is not reproducable. It is equal to the Visual Studio where from time to time all toolbars are reordered.
Has anyone of you an idea? It is really urgent.
|
|
|
|
|
One problem could be that you save the toolbar positions when closing the app and its minimized at the time. As doing this will give bogus positions for all the toolbars when they are saved, I think.
Also, when re-sizing the main window, the toolbars are moved usually by the MFC code if the new size causes a docked toolbar to not be able to show all its buttons.
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
There is no problem with saving the toolbar positions when closing the app minimized. The problem is that my toolbars must be moved before saving.
Example: I have 3 toolbars and the positions are
toolbar1 toolbar2 toolbar3
after closing I have always the position like
toolbar1
toolbar2
toolbar3
Only the y-values are changed. The value has exactly the hight of my toolbars. The big problem is that it happens rarely so that in general everything must be ok.
|
|
|
|
|
Hi!
I'm trying to use two diferent CFont objects to use in diferente CStatics, but one of them is never used, why does this happends, i did like :
void CUnits_Sold::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
//trata das fontes para os títulos
CFont hFont;
CFont hFontForm;
hFont.CreateFont(40, 15, 0, 0, FW_BOLD ,FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "MSTrebuchet");
m_stCStatic.SetFont(&hFont);
m_stCLabel.SetFont(&hFont);
m_stCMachineName.SetFont(&hFont);
m_stCTempo.SetFont(&hFont);
m_stCTempo2.SetFont(&hFont);
//cria a fonte para as letras de identificação do form
hFontForm.CreateFont(200, 14, 0, 0, 0 ,FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "MSTrebuchet");
m_stCFormName.SetFont(&hFontForm);
}
This hfontform is not used and the m_stCFormName uses the hFont, what am I doing wrong?
Thank you for your time
Rui
|
|
|
|
|
As soon as the CFont objects go out of scope, they are destructed. The CFont destructor destroys the GDI font objects. Make the CFont variables members of the view class.
--Mike--
"Adventure. Excitement. A Jedi craves not these things."
-- Silent Bob
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thank you Michael Dunn, it's working!
Rui
|
|
|
|
|
Hi all,
I am using the CHttpFile wrappers class in MFC. On one of my test networks I periodically see an issue where I send a POST command to a Java Servlet on my server, and my client times out waiting for a response (about 30 seconds). However if I type the same URL into IE I get the repsonse back ok. And if I reboot my machine the POST command starts working in my client.
My question is, does anyone know of an issue with the CHttpFile classes or Internet APIs with IE that would cause this, or possibly a mistake that I could have made in using them that would cause this?
Thanks
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I don't exactly know the cause. But I suggest you to check the HTTP header and data that the client send to HTTP server.
You should make sure that your HTTP header is a correct POST header, and you POST data have the same length that you specify in POST header.
If you request is incorrect, the server will wait until it recieves the correct request. And that may be the cause that make your client doesn't recieved response from server.
And I additional suggest you that you should close the connection every time you connect to server.
|
|
|
|
|
Hi I developed an RAS software. When I run on Windows ME and later it works fine. I dont know about windows 98. But when I run it on Windows 95 it crashes when i try to delete RAS entry. Code is below. It works fine if i add one more line of MessageBox.
CRASHING CODE<br />
m_ras.DeleteRasEntry();<br />
<br />
The function looks like this.<br />
BOOL CMyRas::DeleteRasEntry()<br />
{<br />
DWORD dwResult=RasDeleteEntry(NULL,strBrand);<br />
if(dwResult!=0)<br />
return FALSE;<br />
return TRUE;<br />
}<br />
Not crashing one. This one doesnt crash else it crashes.
<br />
BOOL CMyRas::DeleteRasEntry()<br />
{<br />
DWORD dwResult=RasDeleteEntry(NULL,strBrand);<br />
TMessageBox("Out of entry");
if(dwResult!=0)<br />
return FALSE;<br />
return TRUE;<br />
}
One more thing. Program also crashes while trying to open a website by calling ShellExecute. It wasnt crashing earlier. But does now.
It doesnot crash if I call RasDeleteEntry as global.
m_ras.DeleteRasEntry();
RasDeleteEntry(NULL,m_ras.strBrand);
I have some global variables a total of going above 1.2KB . So I tried to convert one of 700 bytes to heap by calling GlobalAlloc but still it doesnt work at all. It crashes again and again.
help me plz.
THanks in advance.
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
<br />
struct InterfaceA<br />
{<br />
virtual void my_interface_func() = 0;<br />
};<br />
<br />
class Class : public InterfaceA<br />
{<br />
void my_interface_func() { }<br />
};<br />
AND
<br />
class InterfaceA<br />
{<br />
public:<br />
virtual void my_interface_func() = 0;<br />
};<br />
<br />
class Class : public InterfaceA<br />
{<br />
void my_interface_func() { }<br />
};<br />
Is there any advantage in using either and if so, what is it?
Thomas
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
modified 29-Aug-18 21:01pm.
|
|
|
|
|
a struct in C++ is a class with all member public by default.
a class in C++ is a struct with all member private( or protected, don't remember ) by default.
so, struct and class can be interchangeable! In your example, they are the same.
Max.
|
|
|
|
|
|
Thomas George wrote:
Why is it that interfaces are always structs then?
maybe because everything should be public by default.
Thomas George wrote:
Is there any performance advantage OR is it that people are lazy to write public: ?
I think the struct/class (the same for public/private/protected ) , is a compilation hint, it does not change the object ( in memory ), or the "performance" of an object.
Max.
|
|
|
|
|
Thomas George wrote:
Why is it that interfaces are always structs then?
Is there any performance advantage OR is it that people are lazy to write public: ?
I got intrigued by this because I always used class for creating interfaces and then I see the line #define interface struct in MSDN. I wondered why?
It is done so they can be used in regular C code, too.
I see dumb people
|
|
|
|
|
|
Hello,
I have an ActiveX Control which is embedded in another application which works fine.
The only problem is that
some peers want to test the control in the application before we ship the
product. From my point of view:
Automated Tests = COM, so I came up with the idea to make a second COM interface
and register it in the ROT (Running Obect table). This Interface gives
full access to my ActiveX control.
I have not done this before so I would like get some opinions how
this could be done in the best object oriented way.
Can I use the same .ODL file for my ActiveX project and insert
there the second interface ? What must I do to implement a second COM interface
by myself ?
Yours,
Alois Kraus
|
|
|
|
|
There are two basic ways to expose a secondary interface:
a) local classes (MFC does that, including some dirty tricks to make this effective)
b) multile inheritance (ATL does that)
b) is IMO much cleaner, only you can get into problems with method name clashes
Some pseudocode for the latter:
class CCoImpl : public IFun, public ITest
{
HRESULT QueryInterface()
{
if (iid == IUnknown) {
addref, return static_cast<IFun *>(this);
}
if (iid == IFun) {
addref, return static_cast<IFun *>(this);
}
if (iid == ITest) {
addref, return static_cast<ITest *>(this);
}
return E_NOINTERFACE;
}
HRESULT GoShopping() { ... }
HRESULT GoRocking() { ... }
HRESULT TestCountShoes(....) { ... }
};
you get the idea...
Neither way you can expose two dispatch (or dual) interfaces - you can only have obe dispatch-based interface per object.
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
How can I get the visible area of a window's CDC(In the paint function)?
I am trying to draw a grid, but drawing it on the whole thing would be wasteful(It's big!)
|
|
|
|
|
Huh ?
You normally draw in the client area of a window ( GetClientRect ), should be clipped, for additional clipping, look for them in the CDC help of MSDN.
Max.
|
|
|
|
|
Use the function ::GetRandomRgn with the SYSRGN flag. You may need to download the most current SDK headers in order to use this function.
I have written this article on clipping regions:
http://www.codeproject.com/gdi/cliprgnguide.asp[^]
It describes the system region, clipping region and meta region. It also has an example of how to get the imformation that you are asking for.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|