|
I created a right-click menu the only problem is binding it to the cursors x/y position.
HMENU Controls = CreatePopupMenu();
AppendMenu(Controls, MF_STRING, 0, L"Resume");
AppendMenu(Controls, MF_STRING, 0, L"Pause");
AppendMenu(Controls, MF_SEPARATOR, 0, 0);
AppendMenu(Controls, MF_STRING, 0, L"Delete");
AppendMenu(Controls, MF_SEPARATOR, 0, 0);
AppendMenu(Controls, MF_STRING, 0, L"Change Filename");
AppendMenu(Controls, MF_STRING, 0, L"Change URL");
AppendMenu(Controls, MF_SEPARATOR, 0, 0);
AppendMenu(Controls, MF_STRING, 0, L"Check MD5");
TrackPopupMenuEx( Controls, TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON | TPM_HORPOSANIMATION, xPos, yPos, g_hWindow, NULL);
int xPos and yPos are casted globally.
case WM_MOUSEMOVE
xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam);
It's definitely cursor position detection problem.
|
|
|
|
|
You failed to mention the problem!!!
-Saurabh
|
|
|
|
|
The menu doesn't appear where the cursor is!
not binding?!
|
|
|
|
|
Binging menu to mouse does not makes sense and I was not able to understand which binding you were referring to.
Anyway, the coordinates should be in Screen Coordinates System. Use ClientToScreen[^] to convert from window to screen coordinate system.
-Saurabh
|
|
|
|
|
In your right-click handler, have you tried calling GetMessagePos() to get the X/Y coordinates?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Sorry for the strange title but couldn't think of how else to describe this.
The pre-amble is that as a hobby project I am trying to refactor some old, very unweldy C Dlls to use C++ classes to make maintenance and general understanding of what is happening a lot easier.
The problem is that many people already already call these Dlls and thus my understanding is that if I make it into classes (unless I add a lot of #defines which is what I'm trying to avoid) it would break a lot of stuff. The one lucky thing is that the old C Dlls exported only a few functions and everything was routed through those functions (basically a giant switch statement to determine what processing to do internally).
I am trying to see if there is another way to hide the fact that internally the Dll uses classes so that C code can call it without worrying about it. Any thoughts?
|
|
|
|
|
I am little confused, how can your hobby project break other people stuff.
Also I am not sure what exactly is your problem. You don't necessarily have to export all symbols from a DLL, like the C version of the DLL you talk about. You can redesign you functions into set of classes and choose not the export them. Then you can make the functions exported in the C DLL call these class to do the job. This way it won't break the interface.
-Saurabh
|
|
|
|
|
If you expose the same interface from that DLL, it doesn't matter if you implement it internally as C, C++ or Ada - it won't break the people who use the DLL.
So...keep those interface functions and re-route them to use your classes internally and you should be good.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Hi,
Thanks for the answer. Looking at it it is quite obvious that I was just over-thinking this whole thing. I guess I was worried about where to instantiate and destroy the class but I could just do that within the exported function I suppose.
|
|
|
|
|
The code is problematic free, yet the JumpList does not get created!
ICustomDestinationList* pJumpList = NULL;
if (SUCCEEDED(CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pJumpList))))
{
pJumpList->SetAppID(L"MyJumpList");
UINT uMaxSlots;
IObjectArray* pRemoved = NULL;
if (SUCCEEDED(pJumpList->BeginList(&uMaxSlots, IID_PPV_ARGS(&pRemoved))))
{
IObjectCollection* pContents = NULL;
if (SUCCEEDED(CoCreateInstance(CLSID_EnumerableObjectCollection, NULL,
CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pContents))))
{
IShellLink* pLink = NULL;
IPropertyStore* pStore = NULL;
PROPVARIANT var;
if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pLink))))
{
pLink->SetPath(L"C:\\md5summer.exe");
pLink->QueryInterface(IID_PPV_ARGS(&pStore));
InitPropVariantFromString(L"Launch MD5Summer", &var);
pStore->SetValue(PKEY_Title, var);
pStore->Commit();
pContents->AddObject(pLink);
pStore->Release(); pStore = NULL;
pLink->Release(); pLink = NULL;
IObjectArray* pContentsArr = NULL;
pContents->QueryInterface(IID_PPV_ARGS(&pContentsArr));
pJumpList->AddUserTasks(pContentsArr);
pJumpList->CommitList();
}
}
}
}
|
|
|
|
|
|
LOL
I know that part, but I've copied that code from the Windows 7 Developer book.
|
|
|
|
|
Copying from book does not make it correct. I work on simple principle - if something is not working then it is broken and needs to be fixed. It doesn't matter who created it and what means are used to create it.
-Saurabh
|
|
|
|
|
Actually the code is working fine!
I found the problem, the problem is when I call the function that executes the JumpList creation.
If I call it to early and some of the wheels aren't spinning it doesn't work.
If I call it later it works.
|
|
|
|
|
|
I would like to know what everyone uses to create standalone help files for application that do NOT have access to the iNet. You know your standard *.chm files.
We have used RoBoHelp in the past but are looking for something easier.
Thanks in advance
Tony Teveris
Gerber Scientific Products
Senior Software Engineer
Phone: 860 648 8151
Fax: 860 648 8214
83 Gerber Road West
South Windsor, CT 06074
|
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
'HelpScribble' is good. (www.helpscribble.com)
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
|
|
|
|
|
Hello guys,
I'm trying to write a simple class in c++ including a short constructor.
Despite the fact that there are no obvious mistakes, there's always the same error message
C2512: no appropriate default constructor available
I do not call the default constructor, but my self written one, also the parameter lists match.
Does anyone already know this problem? If not I can post the listings.
Thanks and best wishes.
|
|
|
|
|
Austrian_Programmer wrote: Does anyone already know this problem?
Yes, provide a default constructor (one accepting no arguments). If that does not work, see here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
If you've written a constructor with parameters, it is not called default constructor.
Default constructor is one with no parameters.
The object you're creating from the class probably needs a default constructor.
|
|
|
|
|
A default constructor is one provided by the compiler -- if you write one that takes no parameters it's not a default constructor.
Edit: Oh, I see, I wound up in the C++ forum somehow...
In C#, "default constructor" actually means something more than "parameterless constructor":
"
10.10.4 Default constructors
If a class contains no instance constructor declarations, a default instance constructor is automatically provided.
"
modified on Tuesday, April 27, 2010 6:00 PM
|
|
|
|
|
The C++ standard defines that "a default constructor is a constructor that can be called without arguments". (ISO/IEC 14882)
|
|
|
|
|
You are wrong. The default constructor is the constructor without arguments. Incidentally, if you don't write any constructor for your class then the compiler provides the default constructor for you.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|