|
Code-o-mat wrote: Currently i am unable to test it
Just paste it into a simple console app and call from main() , takes but a few minutes to test.
Your alternative appears to be an equally good solution. Without knowing a lot more about your project it's difficult to offer much more advice. Either way you seem to have the answer at your fingertips.
[edit]spelling[/edit]
|
|
|
|
|
Thank you for the suggestion, i sometimes do that too, should have thought of it this time too, guess i am tired. Aside of this, see my other post[^] for the "solution"...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I think your signature(s) say it all.
I'm sure you'll get it right after a good night's sleep ... and maybe some beer.
|
|
|
|
|
In your first example, the one without the C-style cast, the type system should prevent you from performing an illegal assignment -- in other words the right thing would have to happen or a compiler error be generated. Because the compiler will not allow the following:
typedef int(* FUNC_ONE)(int);
int Func2Parm(int x, int y)
{
return x + y;
}
FUNC_ONE pFuncOne = Func2Parm;
Once you introduce the explicit cast, I am not sure what will happen. I would have guessed that the compiler would report an ambiguity error (after all it could cast either pointer that way).
|
|
|
|
|
Code-o-mat wrote: I declare two function pointer types [...]
Have you considered using C++ virtual functions[^]... just a suggestion.
|
|
|
|
|
Thanks for the suggestion but i don't see how that would apply to this situation.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Well, when I saw function pointers I thought that the design pattern you try to implement is something like a callback or interchangeable functionality. In object oriented languages, polymorphism (virtual functions or delegates) provides exactly that and under the hood they are more or less function pointers, with the advantage that the compiler takes care of most things automatically (type safety, calling context). It could be worth to have a look at these possibilities.
For using virtual functions define a interface (pure virtual base class) that you can override:
class IFunctionInterface
{
public: virtual int Func(int x) = 0;
public: virtual int Func(int x, int y) = 0;
};
class CFunction1 : public CWhatever, public IFunctionInterface
{
public:
CFunction1 ();
virtual ~CFunction1 ();
int Func(int x) { return x; }
int Func(int x, int y) { return x + y; }
};
class CFunction2 : public CWhatever, public IFunctionInterface
{
public:
CFunction2 ();
virtual ~CFunction1 ();
int Func(int x) { return x + x; }
int Func(int x, int y) { return x * y; }
};
For delegates have a look at Boost library (function/bind/signal) or Fast C++ Delegates[^] here at CodeProject.
Hope this helps.
/M
|
|
|
|
|
Hai,
I am Having A MFC DialogBox & I want to store some values to the DataBase.Can Any One Tell Me how to do this?Previously I haven't worked with Any Data Base Application.Can AnyOne Give Me Simple Examples On this.
Thanks
|
|
|
|
|
A lot of information is available here[^]. For examples you can browse the content on codeproject
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
|
Hi,
I am using CListControl in Dialog and one of the column is checkbox.How would I capture change (check/uncheck) in checkbox in any of the row.Thanks for help.
Regards
|
|
|
|
|
itkid wrote: I am using CListControl in Dialog and one of the column is checkbox.
Did you actually put a check box in each row of that coloumn or just an ICON of check/uncheck marks?
|
|
|
|
|
conditional checkbox is present in few row. I just want to capture any change in any checkbox.
|
|
|
|
|
I hope you are showing the check box with LVS_EX_CHECKBOXES. If so, you will get the LVN_ITEMCHANGED notification when user checks or unchecks the check box. you can identify the state of check box by getting the state image of the item.
From MSDN:
"State image 1 is the unchecked box, and state image 2 is the checked box. Setting the state image to zero removes the check box."
|
|
|
|
|
how to contact the file extension with file type?
as we know, you can check the option of hidden known file extesion in windows, but how do we identify file extension through file type
|
|
|
|
|
try the SHGetFileInfo() with the SHGFI_TYPENAME flag.
|
|
|
|
|
You would need to know the format of each type of file that may exist. This information is specific to each application and is not something maintained by Windows itself.
|
|
|
|
|
|
You could try gettin an IShellFolder[^] interface of the desktop, maybe by using SHGetDesktopFolder[^], use its EnumObjects[^] method to enumerate the objects on the desktop, on every object you get, use GetUIObjectOf[^] to retrieve IExtractIcon[^] for it and then use the ExtractIcon[^] method of that to get an icon.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Hi,
I make one dialog with pos as follow
SetWindowPos(&CWnd::wndBottom,0,80,350,900,SWP_SHOWWINDOW);
But when i changed the resolution to 800x600,half of dialog get hided.
How can i avoid that?
I want in all resolution the dialog should display in same size.
Anu
|
|
|
|
|
You can handle WM_DISPLAYCHANGE message in your application and call SetWindowPos(...) to readjust the size.
|
|
|
|
|
Anu_Bala wrote: SetWindowPos(&CWnd::wndBottom,0,80,350,900,SWP_SHOWWINDOW);
But when i changed the resolution to 800x600,half of dialog get hided [...] I want in all resolution the dialog should display in same size.
Well, you can't have a 900 pixel high window in a 600 pixel high desktop.
Cheers,
M
|
|
|
|
|
You can adjust your sizes with respect to maximum width and height available.
for example
your ratio for 900(in 1028x1024) is 900/1024 and for 800x600, it will be 600*900/1024.
Perhaps this[^] could also help.
|
|
|
|
|
By way of pointing out the obvious -- if you have an 820 pixel high dialog on a 600 pixel high display, part of it will be cut off no matter what.
|
|
|
|
|
how to get Window name from window handle in win32.
|
|
|
|