|
Hi,
U have to use the Recordset to bind the dilaog controls to the
recordset fields.
U can do this by the RFX_ macros and attaching by using the DDX macros
by hand, that's a little tediuos, but
u can do automatically in the following manner.
1. When the Dialog is open in the Resource Window.
2. Select a control and open class Wizard(Ctrl+W)
3. Then depending on the control u selected and to the
field u want to display in the control
4. Select the control and go to the 'Members Variables' tab
5. Select the control and press 'Add Variable'
6. In the Member vaiable name --> Select the Recordset field u want
to associate.
Phew,
Thats all.
|
|
|
|
|
thank you could not be easier
|
|
|
|
|
can i cast a member func ptr to global func ptr
(without a compilation error...)?
typedef void (*Func)();
class Moo{
void Do();
void Cast_A_Func(){ m_fn = (Func)(void*)Do; } //Or something like that...
Func m_fn;
};
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
No, because member functions have 'this' as their first argument (although you don't write it that way). Your code will work only if Do() is static, since static methods have no this pointer.
--Mike--
http://home.inreach.com/mdunn/
"Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Well, if you're in desperate need of treating a pointer to member function as a regular pointer to function, and you can afford changing the calling convention of your member function, then there is a tricky, heavily non-portable workaround: Consider the following class:
class A
{
public:
int __cdecl f(int a_){a=a_; return a+1;}
private:
int a;
}; From the point of view of the compiler, A::f is called like a regular function having a first hidden parameter that provides the this pointer. That is, the types PMEMBFUNCTION and PFUNCTION , defined as
typedef int (__cdecl A::* PMEMBFUNCTION)(int);
typedef int (__cdecl * PFUNCTION) (A*,int); are equivalent in the sense that the compiler generates the same code to execute calls for them. Alas, this kind of equivalence does not allow us to force a cast between the types. So the snippet of code
A a;
PMEMBFUNCTION pmf=A::f;
PFUNCTION pf=reinterpret_cast<PFUNCTION>(pmf); does not compile: from the compiler point of view, the types involved are wildly disimilar. Tricks like trying an intermediate cast to void * do not work either.
Not all hope is lost, nevertheless. We can use a last resort to force the casting. This struct
struct caster{
union{
PMEMBFUNCTION pmf;
PFUNCTION pf;
};
}; implicitly does the casting for us: the union allows us to store a PMEMBFUNCTION and retrieve a PFUNCTION . This kind of "casting" is even stronger than the allmighty reinterpret_cast !
So here's a complete program that shows how to call A::f as a regular function, providing the extra this parameter. I hope the technique is clear after this exposition.
#include <iostream>
using namespace std;
class A
{
public:
int __cdecl f(int a_){a=a_; return a+1;}
private:
int a;
};
typedef int (__cdecl A::* PMEMBFUNCTION)(int);
typedef int (__cdecl * PFUNCTION) (A*,int);
struct caster{
union{
PMEMBFUNCTION pmf;
PFUNCTION pf;
};
};
int main(void)
{
A a;
caster c; c.pmf=A::f;
PFUNCTION pf=c.pf;
cout<<pf(&a,666)<<endl;
return 0;
} One major drawback of this trick (apart from being scandalously non-portable) is that the member function has to be declared with the __cdecl calling convention. Why is this so? Well, if no calling convention is specified, the compiler uses the default __thiscall . In this calling convention, normal parameters are passed to the member function as in __cdecl , but the this pointer is stored in register ECX. You cannot simulate this behavior when calling a regular function, unless you use some assembly code.
Also, this definitely does not work with virtual member functions.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hello!
i have a problem with SendInput function...
i need to simulate the Ctrl+C... and after it i'm getting the text string from Clipboard...
but there is a delay between the SendInput is called and the keys are simulated... and when i'm getting the text from Clipboard, i'm getting the old Clipboard data...
what should i do?
maybe i need to use some delay function after SendInput?...
if you know any delay functions, please tell me...
|
|
|
|
|
Install a clipboard viewer, and you'll know exactly when the contents of the clipboard change. See my article ClipSpy in the clipboard section, which demonstrates a clipboard viewer.
--Mike--
http://home.inreach.com/mdunn/
"Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001
Sonork - 100.10414 AcidHelm
|
|
|
|
|
I have an SDI app where the CMainFrame is broken up with static CSplitterWnds. When I create the view (CKeypadView) with CreateView() it properly passes in the pointer to the CDocument.
m_splRightCol.CreateView( 2, 0, RUNTIME_CLASS(CKeypadView), CSize(0,0), pContext )
When I break when the OnUpdate() is called from the OnInitialUpdate() the pointer now reads NULL. Why?
------------------------------------------------
I am not discouraged because every wrong attempt discarded is another step forward
-- Thomas Edison --
|
|
|
|
|
Hello, the codegurus around the world.;)
OnInitUpdate() function is called a couple of times before acutally
its view is created (?) or is visiable.
So, you must add the validation code to check if some controls in OnInitUpdate() have their own HWND or CWnd (not NULL).
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
I removed the code that tries to access the CDocument from OnUpdate(), but even when I try to access the document later on (using GetDocument() ), it still doesn't have a pointer to the document. All other views still have a valid pointer.
Make no little plans; they have no magic to stir your blood to action. Make big plans, aim high in work and hope.
-- Daniel Burnham
|
|
|
|
|
I was wondering... is it possible to create an executable (.exe) that has a dll entry-point as well as a normal application entry-point, that is: a WinMain function that would be called when the file is executed, and a DllMain that would be called if the file is loaded by LoadLibrary (or something similar).
Thanks for any info
Enjoy!
Marc
|
|
|
|
|
That is a curious question. I do not know but you could give it a try. Place those and a few other functions in your .exe's code and put "__declspec(dllexport)" in front of them and see what happens. Run "dumpbin /EXPORTS" at a command prompt to see if it really worked.
I do a related thing in my company's product. We often run multiple instances (sometimes dozens) of the same process so I have nearly all of the code in a DLL. The main function for this process looks like this :
int main(int ac, char*av[])
{
return MyLibrary(ac,av);
}
This gives each process minimal memory usage.
|
|
|
|
|
Mark:
A dll and a exe are similar, you can export function from a exe or from a dll, you can make all a application that is in a dll. The diference is that you need to know that you are calling a dll or a exe, because if you are calling a exe, this will be callin the winmain function or other function that you want to determine how entry point, but if you are calling a dll that have a application in, you need to know the ameof the function...
Sometimes I make that, I make a exe and this app, call dll like plugins....
best regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
I know, but I was just wondering if it was possible to have both things in one file. Of course, it is possible to export functions from the exe file, but if it needs to be able to initialize itself before these functions are called a DllMain function would be nice in addition to WinMain. (of course, i could call an initialization routine from the exported functions, but that's not as fun )
Actually what I'm trying to do is to make an .exe file which hosts shell extentions This way I would only have to distribute one file, and not an external dll
Enjoy!
Marc
|
|
|
|
|
When I use the menu command
Project>Add to Project>Components and Controls
VS opens the gallery window as it should, but it is empty. No ActiveX controls are listed. I checked the path, and it is opening into the 'Gallery' folder. So, in my attempts to figure out what the heck is up, I tried to add a (known) ActiveX control from my C:\WINNT\SYSTEM32 folder. Visual Studio complained that the control was not registered. So, I fired up the ActiveX Control Test Container to check out what controls are registered. The Test Container listed quite a few controls; all of the controls that should be listed in my Gallery window.
Anyway, as I see it, this all proves one thing...the ActiveX controls are all registered correctly on my computer, but for some reason Visual Studio doesn't know how to find them...any suggestions?
I'm running Windows2000, and I have the latest VS update, for all that's worth. Thank you very much for any help, I'd really like to have this functioning like usual.
~Cam Desautels
|
|
|
|
|
This is a good question. It's happened to me in the past as well and I've never known why. I hope someone has an answer.
Regards,
Alvaro
|
|
|
|
|
Hi Search for the following topic in MSDN,
It might be of some help.
"Reusing Code Topics"
|
|
|
|
|
Yes, i had actually checked out a number of these topics, but I did find something interesting:
The Gallery regenerates links to registered ActiveX controls every time you open it, based on the current state of the registry. This has certain implications:
If you delete a link to a registered ActiveX control, the link will still appear the next time you open the Gallery.
If you delete a registered ActiveX control (.OCX or .DLL file), but do not unregister it, the link will still appear the next time you open the Gallery. Of course the link will be inoperative.
If you copy an ActiveX control to your machine, but do not register the file, the link does not appear because the Gallery does not recognize the control.
...anyway, the important part is that the list is regenerated from the registry. I figured as much, but that doesn't explain the problem...grr...
|
|
|
|
|
I am creating a wizard using VC++ MFC, but I'm having trouble adding a bitmap header to the property sheet. My bitmap gets clipped by the property pages. What is the standard procedure to accomplish this?
Paul Jahans
|
|
|
|
|
If what you want is to allocate a little more space on top of the property sheet, add this snippet on your OnInitDialog() :
CRect rectWnd;
GetWindowRect(rectWnd);
SetWindowPos(NULL, 0, 0,
rectWnd.Width(),
rectWnd.Height() + 100,
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
CWnd *pWnd=GetWindow(GW_CHILD);
while(pWnd!=NULL){
CRect rect;
pWnd->GetWindowRect(rect);
rect.OffsetRect(0,100);
ScreenToClient(rect);
pWnd->MoveWindow(rect,FALSE);
pWnd=pWnd->GetNextWindow();
}
(Of course you'll want to change the offset to fit the dimensions of the bitmap header.)
Joaquín M López Muñoz
Telefónica, Investgación y Desarrollo
|
|
|
|
|
I have added a Menu Item to Popup default item File. After adding the Coommand Handler, when I run the app, the Menu item that I added appears Grayed. I am not sure why that is happening when the properties are not set to be disabled nor the code is written to do so. What would make the item Enabled or non-grayed by default.
|
|
|
|
|
Well, seems like MFC is not being able to locate the Command handler you wrote for that menu item. You could check if the handler is correct by creating a non popup menu (a fixed menu on the main windows, for instance) and inserting a menu item with the same ID. If the command handler is correct that item should be enabled (and the problem lies elsewhere).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
When I drag the Item to main bar, it is not grayed. Only when I nest it in the File option, it gets Grayed. I have the OnUpdateYourMenuItem too. Tried adding code to ENABLE the Item and still no luck.
|
|
|
|
|
Do you have a a OnUpdateYourMenuItem(CCmdUI *pCmdUI) handler for this menu item ? If you don't the menu item is disabled by default.
|
|
|
|
|
I did edit the ID few days back but, surprisingly, it doesn't behave that way when I have it at top level. Only when I make it a subitem, or within a popup, it gets grayed for no reason. I rebuild the files but no effect.
|
|
|
|
|