|
DavidCrow wrote: this menu is the same one that Explorer uses
What do you mean by that ? you load the explorer menu or just make it look like the exporer menu?
I think you need to have handlers for you menu item; or you can use the option TPM_RETURNCMD to have TrackPopupMenu return the item selected item; then you will need to handle the state of the items manually.
Watched code never compiles.
|
|
|
|
|
Maximilien wrote: What do you mean by that ? you load the explorer menu or just make it look like the exporer menu?
Meaning it is one in the same. I go through all of the COM and Shell stuff to create and display the context menu, like:
LPSHELLFOLDER folderParent;
DesktopFolder->BindToObject(pidlParent, 0, IID_IShellFolder, (LPVOID *) &folderParent);
LPITEMIDLIST pidlFile;
folderParent->ParseDisplayName(AfxGetMainWnd()->GetSafeHwnd(), 0, (LPWSTR) ((LPCTSTR) strFile), &ulEaten, &pidlFile, 0);
LPCONTEXTMENU CM;
folderParent->GetUIObjectOf(AfxGetMainWnd()->GetSafeHwnd(), 1, (LPCITEMIDLIST *) &pidlFile, IID_IContextMenu, 0, (LPVOID *) &CM);
HMENU hMenu = CreatePopupMenu();
DWORD dwFlags = CMF_CANRENAME;
CM->QueryContextMenu(hMenu, 0, 1, 0x7fff, dwFlags);
int Cmd = TrackPopupMenu(...);
Maximilien wrote: ...or you can use the option TPM_RETURNCMD to have TrackPopupMenu return the item selected item...
All of the menu items are gray, so TrackPopupMenu() is only going to return 0 .
"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
|
|
|
|
|
thanks. I did not know that (getting the explorer menu).
(you could do a tip/tricks entry for that!, but for now, I'm just bookmarking it).
Max.
Watched code never compiles.
|
|
|
|
|
Maximilien wrote: (you could do a tip/tricks entry for that!, but for now, I'm just bookmarking it).
I'm actually working on an actual application that uses this stuff. Once done, I'll see if it's post-worthy.
"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
|
|
|
|
|
Is there any inbuild function available to implement Incremental Search in CRicheditview?
|
|
|
|
|
According to MSDN FindText[^] can search starting from a given character position. Use the chrg and chrgText members of the FINDTEXT[^] structure to set and get the ranges, and lpstrText to set the text to search for.
Edit: this is for rich edit
|
|
|
|
|
Hello,
i use C++ with Windows Forms for development.
As you knows in form we can use many controls and i want 2 re size each control as per the system resolution. so if anybody knows then please help me.........
|
|
|
|
|
ddgalande wrote: i want 2 re size each control as per the system resolution.
I am not sure what problem you are having with this but you can get the screen resolution from the GetSystemMetrics()[^] function. How you use that information to resize your controls is up to you, but I presume you just want to apply some scaling to them.
I must get a clever new signature for 2011.
|
|
|
|
|
hi,
i did not got your answer.
My question is that suppose my screen resolution is 1024x768 and i have designed my GUI as per the current resolution.
by using following code i can get my systems current resolution
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
MessageBox::Show("Screen Resolution is : " +monitor_width +" x " + monitor_height, "Dnyan", MessageBoxButtons::OK, MessageBoxIcon::Information);
double xRatio = monitor_height / 800.00;
double yRatio = monitor_width / 600.00;
}
public: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
monitor_height=Screen::PrimaryScreen->Bounds.Height;
monitor_width=Screen::PrimaryScreen->Bounds.Width;
}
Now suppose my project is in network and one persons system resolution is 800x600 second person screen resolution is 1024x768 and others is different
in this case i want to adjust control default location as well as its size as per screen resolution
then please tel me how its possible in C++ with Windows platform (in .net IDE)
Please help me
|
|
|
|
|
You will need to adjust the size of your form, and all the controls, before you display it. I would guess that you need to find some calculation that will optimise it for different size screens. It would probably be best to design it for the lowest resolution and adjust upwards for the higher ones.
I must get a clever new signature for 2011.
|
|
|
|
|
I am sure there are some articles covering that subject here on CP. Just look in the Dialog and Windows article section.
|
|
|
|
|
Hi all,
I am using SortItems function to sort my list. I am using it this way
m_list.SortItems(2,TRUE);
In Visual studio 2008 its compiling ok but in VS-2010 its giving a error
error C2664: 'CListCtrl::SortItems' : cannot convert parameter 1 from 'int' to 'PFNLVCOMPARE'
to remove this error i write my line in this form
m_list.SortItems((PFNLVCOMPARE)2,TRUE);
the error is removed but it is not sorting the list either...
How can i make it work ?
Thanks in advance
|
|
|
|
|
According to MSDN[^], you must pass the address of a 'comparison function' (have also a look at the provided code sample).
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]
|
|
|
|
|
using this method also gives same error
error C2664: 'CListCtrl::SortItems' : cannot convert parameter 1 from 'int (__stdcall CItemDlg::* )(LPARAM,LPARAM,LPARAM)' to 'PFNLVCOMPARE'
|
|
|
|
|
Please show us both the code and the error.
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]
|
|
|
|
|
m_List.InsertColumn(0,"Name",100,100);
m_List.InsertColumn(1,"Number",100,100);
m_List.InsertItem(0,"Item1");
m_List.SetItemText(0,1,"2");
m_List.InsertItem(1,"Item2");
m_List.SetItemText(1,1,"3");
m_List.InsertItem(2,"Item3");
m_List.SetItemText(2,1,"1");
I want to sort these items according to second column i.e "number" column
int CALLBACK CItemDlg::MyCompareProc(LPARAM lParam1, LPARAM lParam2,
LPARAM lParamSort)
{
UNREFERENCED_PARAMETER(lParamSort);
return (int)(lParam1 - lParam2);
}
void CItemDlg::OnBnClickedButton1()
{
m_List.SortItems(&CItemDlg::MyCompareProc, 0);
}
when i compile this code, it shows this error
error C2664: 'CListCtrl::SortItems' : cannot convert parameter 1 from 'int (__stdcall CItemDlg::* )(LPARAM,LPARAM,LPARAM)' to 'PFNLVCOMPARE'
Thanks for helping
|
|
|
|
|
MyCompareProc cannot be an ordinary member of the class (must be a global function or a static class member). We should blame MSDN for providing a broken code sample.
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]
|
|
|
|
|
Should be:
m_List.InsertColumn(0,"Name",100,100);
m_List.InsertColumn(1,"Number",100,100);
int x = m_List.InsertItem(0,"Item1");
m_List.SetItemText(x,1,"2");
x = m_List.InsertItem(1,"Item2");
m_List.SetItemText(x,1,"3");
x = m_List.InsertItem(2,"Item3");
m_List.SetItemText(x,1,"1");
int CALLBACK MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
UNREFERENCED_PARAMETER(lParamSort);
return (int)(lParam1 - lParam2);
}
void CItemDlg::OnBnClickedButton1()
{
m_List.SortItems(MyCompareProc, 0);
}
"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
|
|
|
|
|
|
I want to display image which is in fits format in my application like an image viewer.
thanks in advance
|
|
|
|
|
Have you tried checking out the libraries on the NASA website[^]?
|
|
|
|
|
I need to get desktop rect, which excludes start-bar, how?
|
|
|
|
|
includeh10 wrote: I need to get desktop rect, which excludes start-bar, how?
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
Just for completeness, if you wanted to include the taskbar:
RECT rect;
::GetWindowRect(::GetDesktopWindow(), &rect);
|
|
|
|
|
If you have multiple monitors, the method mentioned by Hans Dietrich may not work. In a multiple monitor environment, different settings may require special treatments. For example, on some systems, the task bar may not be stretched to the full width of the whole virtual desktop. In this case the work area on those monitors without the task bar will be larger than the one with the task bar. Then again the task bar can be stretched to all monitors. This means the work area cannot be simply expressed by a rectangle.
You can find more information on virtual screen by searching the web.
|
|
|
|
|
This is probably a dumb question, but I was examining the vector class source code (Visual C++ 2003) and noticed some method definitions that were confusing me. After some thought, I got on this tangent about template definitions in general and started to question why all the method definitions needed to be "templatized" (for lack of a better word) if some methods never dealt directly with any "typename" for the template.
In other words, if a template method (lets call it "GetVersion") did something simple like return an integer constant, irregardless of any "typename", and the class was instantiated twice, lets say...
CMyClass<int> first;
CMyClass<float> second;
and then somewhere in the code, each instance (first and second) calls "GetVersion", I'm assuming only one copy of "GetVersion" gets created by the compiler.
If this is true, why does the method definition need to "templatized"? Or Does it need to be "templatized"?
The code for vector almost appears to be taking advantage of some technique that only bothers with template syntax for the methods that deal with any typename but I could easily have been deceived. Is it possible to define non-templatized methods in a template class or am I just off my rocker? Or does the compiler require template syntax for every method? (So far, I only get compiler errors if I try to omit template syntax for such methods so I'm guessing I've strayed from reality a bit here but I thought I'd ask anyway)
|
|
|
|
|