|
I am doing a work like a monitor.
I mean when I click some file'icon on the desktop , for example ,system will return a messagebox says "this file's path is ...".
How can the system know what I have chosen?
I need system return the file's path.
|
|
|
|
|
I personally don't know any standard way to do what you want (which of course does not mean there isn't any).
You could try hooking into explorer.exe, subclass the list control that hosts the icons on the desktop, or the window that receives notifications from the list view, or installing a (system-wide?) message hook, to find out when and to what the selection changes. Then you could use SHGetDesktopFolder[^] and use IShellFolder::EnumObjects[^] to find the path for the selected item, if it has any. How you would find out which icon belongs to which shell objects is beyond me at this point, you could try finding that object by the name the icon shows but this is probably a bad idea (for example if i have a "myFile.pdf" and a "myFile.txt" sitting on my desktop, i think both will have the name "myFile", the extension is hidden, or at least can be). If you are lucky then the items' itemdata contains something that can be used to identify them, for example a pointer to a IDList or somesuch, then you could even skip the "look up" part thorough the enumeration. This whole thing is just an idea and not a simple one at that...
> 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. <
|
|
|
|
|
Oh, I am still a freshman and what you said is really hard for me..
Haha, still, thank you very much!
I will try..
|
|
|
|
|
If you are a freshman i recommend starting with something simpler, anyways, good luck.
> 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. <
|
|
|
|
|
yeah, Thank you!
Any problems can I ask you for help?
|
|
|
|
|
Sure.
> 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. <
|
|
|
|
|
Hey everyone, new guy here.
I'm in a Game Physics class where we are learning OpenGL and a little bit of GLUT. In class, the pc's run Win XP and Visual C++ 2005 Express. I can get it to run my code in class with no problem. However, when I come home, for some reason I keep getting linker errors. I'm running Win7 Home Premium 64-bit. I've put the files into what I believe to be the correct folders, but whenever I compile and run, nothing. Anyone have any ideas? I'm starting to get really far behind in class because of this.
Thanks!
|
|
|
|
|
epinez wrote: I come home, for some reason I keep getting linker errors.
epinez wrote: I compile and run, nothing
These conditions are contradictory. If you're having linker errors, what are they?
If you have linker errors, you can't "run".
The wonderful thing about the Darwin Awards is that everyone wins, especially the members of the audience.
|
|
|
|
|
Sorry, should have been more clear. I attempt to compile and run, but nothing. The errors I get are: " error LNK2019: unresolved external symbol..."
Just to give insight to troubleshooting I've tried: I've put the GL and GLUT files in several different places and I've tried uninstalling VC++ and reinstalling it.
|
|
|
|
|
Is GLUT built for 64 bits on your home system or did you bring home the 32 bit libraries?
The wonderful thing about the Darwin Awards is that everyone wins, especially the members of the audience.
|
|
|
|
|
epinez wrote: The errors I get are: " error LNK2019: unresolved external symbol..."
Could you please give the exact error message. It helps to know which library is missing...
|
|
|
|
|
Well unless you tell us what errors linker is compaining about how can we help you?
-Saurabh
|
|
|
|
|
My professor decided it'd be a wonderful idea to have us code a binary search tree. I'm somewhere in my fourth or fifth attempt, and I'm about to break something I'm so frustrated.
So, where I'm at: I've currently got two classes, BST for the tree, and BSTN for the tree's nodes. I'm attempting to write an insert function, and I'm using the pseudo-code from Introduction to Algorithms (3rd ed) to guide me (is it okay to post that pseudo-code on a forum?). I just seem to keep not being able to get my code to work (and please forgive me if I'm a bit slow... I haven't done much with C++ in over a year).
BST.h
BSTN.h
I've opted for pastebin, so I could highlight the specific lines that I'm having trouble with (in BST.h). So, the three I have highlighted are where I've departed from the pseudo-code, and two of them are why I think I need to overload operator==. On line 39, the pseudo-code says to check that currNode is not NULL, but it never evaluates to false if I use the condition currNode != NULL . Line 48 I don't think should be commented out, but if I assign the parent there, if the node happens to be the root, it won't have the NULL parent that it should, so I don't get why they think it ought to be done there. And line 50 should have the condition currNode == NULL , but that will never evaluate to true.
Do I need to overload operator==? If so, how do I do it? I've tried several times and nothing has worked. Or are my slight modifications to the pseudo-code's method going to work fine?
And once this is sorted out, I probably have more questions.
Oh, and I'm using Visual C++ Express 2008.
|
|
|
|
|
Yes it is perfectly fine to post pseudo-code here.
At line 39, you want to check if currNode is not NULL then why are you checking currNode->element == NULL . element is not a pointer and checking if it is equal to NULL is equivalent to checking if it is equal to 0 (Note: NULL is defined as #define NULL 0 ). You should check currNode != NULL , then you don't need == operator.
There is similar problem in the BST constructor. You assign NULL to root->element.
Line 48: I haven't seen the psuedo-code so can't comment how faithful is your implementation. But I will implement it like this.
constructor:
root = NULL;
insert:
if(root == NULL)
create root and set its element to given value.
else
insert element in proper place.
Also it is a good idea to define a constructor for BSTN and initialize its member variables to default value there. Then you can simple do BSTN* node = new BSTN; .
-Saurabh
|
|
|
|
|
I'm feeling like you've missed my problem entirely. My problem is that currNode == NULL and currNode != NULL don't work, even if I don't overload operator== (and once that's overloaded, doing operator!= should be easy). I attempted to overload it so that I could get it to work, but I have been unsuccessful so far. So after overloading wasn't working for me, I tried testing a member variable within a node that will allow me to enter/skip the while loop or if statement, and that's how my code currently stands.
If it might help, here's the book's pseudo-code:
TREE-INSERT(T,z)
1: y = nil
2: x = T.root
3: while x != nil
4: y = x
5: if z.key < x.key
6: x = x.left
7: else x = x.right
8: z.p = y
9: if y == nil
10: T.root = z
11: elseif z.key < y.key
12: y.left = z
13: else y.right = z
(Introduction to Algorithms, 3rd edition, p 294)
|
|
|
|
|
I didn't missed anything at all. I can only see what you present me and your code doesn't check if currNode == NULL
Can you share the code for createNewNode() ? In the constructor you are doing root = createNewNode(); and then later in insert you are assigning it to currNode on line 37. Now if createNewNode is indeed creating a new node then how can currNode can be NULL?
That is exactly why I suggested that root must be initialized to NULL in the constructor.
-Saurabh
|
|
|
|
|
By the way in the psuedo-code x is assigned T.root but it is not mentioned what is the initial value of T.root. I guess the book must have mentioned it somewhere else that it should be initialized to NULL.
-Saurabh
|
|
|
|
|
The way I've been taught binary search trees is that, by definition, the root node is set to NULL when the tree is created.
I was misunderstanding the difference between setting a node to NULL, and setting each of the node's members to NULL. It's been a rough week.
And, yes, the book is indeed assuming that all nodes are initialized to NULL.
I've gotten rid of createNewNode() because it really wasn't doing much for me (I thought it was included earlier, but I guess not).
I was a bit snotty in my previous reply, and I apologize for that. What you've said has helped me think more carefully about what I'm actually doing with the code. (And I appear to have insertion completely working now!) Thank you for the help!
|
|
|
|
|
You are most welcmoe. No worries at all. Good luck with rest of assignment.
-Saurabh
|
|
|
|
|
Is it possible to add icons to a dialog window's title bar? I'd like to add some LED-style status indicators to a dialog-based MFC application which should be shown next to the close/maximize/minimize icons. I imagine it's to do with non-client area painting but I couldn't find sample code. I don't want to create the whole title bar - there are examples around for that - but just add an icon or a bitmap.
|
|
|
|
|
|
It didn't really help. I assume the sample code should go into an override of CWnd::DefWindowProc, so I tried this:
LRESULT CMyDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_NCPAINT)
{
LRESULT lRes = CDialog::DefWindowProc(message, wParam, lParam);
HDC hdc = ::GetDCEx(GetSafeHwnd(), (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN);
if (hdc)
{
CDC dc;
dc.Attach(hdc);
CBrush brush(HS_FDIAGONAL, RGB(255, 255, 255));
dc.FillRgn(CRgn::FromHandle((HRGN)wParam), &brush);
}
::ReleaseDC(GetSafeHwnd(), hdc);
return lRes;
}
return CDialog::DefWindowProc(message, wParam, lParam);
}
A breakpoint on the 'if (hdc)' line would be hit but a breakpoint on the 'CDC dc' line wouldn't, so hdc seems to be 0 all the time
Anyway, thanks for the reply!
modified on Saturday, April 24, 2010 3:52 PM
|
|
|
|
|
hummm .... see the comments at http://msdn.microsoft.com/en-us/library/dd145212%28VS.85%29.aspx#CommunityContent[^]
Looks like MSDN didn't tell the whole story:
Just copied from the user commnt
Getting the device context when handling WM_NCPAINT does not work as described. Additional undocumented flag 0x10000 has to be used:
case WM_NCPAINT:
{
HDC hdc;
hdc = GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW | DCX_INTERSECTRGN | 0x10000);
ReleaseDC(hwnd, hdc);
}
(Verified on Windows XP)
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Thanks emilio_grv, that does make a change. Now the hdc isn't always 0. However, just calling GetDCEx and ReleaseDC (with no code between them) makes the window update so slow that most of the time, parts of the window are not properly redrawn...
|
|
|
|
|
Thanks to all who helped me. I finally found a solution.
1. Insert the ON_WM_NCPAINT() macro into the dialog's message map, and create an overwritten OnNcPaint method.
2. In OnNcPaint, first call the derived OnNcPaint method, then get the paint DC by calling GetWindowDC(), and paint into the DC whatever you want to paint. That's it.
It is a good idea to exit the function before painting if IsWindowVisible() returns false, or if IsIconic() returns true, because there is no visible title bar to paint on.
If you don't want to paint over the close, minimize, etc. icons, you can retrieve their positions by calling GetTitleBarInfoEx. This function is unfortunately not defined in CWnd, so you must define it as
BOOL GetTitleBarInfoEx(HWND hWnd, PTITLEBARINFOEX pstInfo)
{
return ::SendMessage(hWnd, WM_GETTITLEBARINFOEX, 0, (LPARAM)pstInfo);
}
GetTitleBarInfoEx will return FALSE unless running Vista and up, so you must check its return value and call GetTitleBarInfo if the call to GetTitleBarInfoEx is not successful. GetTitleBarInfo is a member of CWnd
If you want to put a flashlight on the title bar, create a timer event which changes a flag (which indicates whether the light is on or off) and then calls RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE); . This will post the WM_NCPAINT message.
What I wrote is for CDialog derived classes. I read (but I haven't tried it) that for MDI applications, you must insert this functionality into the main frame.
modified on Friday, June 18, 2010 3:50 AM
|
|
|
|
|