|
|
Are you wanting something like:
class A
{
int x;
};
class B
{
template<class T> void temp(const T& data){ }
void test(void);
};
void B::test(void)
{
A a;
temp(&a);
};
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
If you're using VC6, change it to
template<class T> void temp(T* = NULL) { } to work around a compiler bug.
|
|
|
|
|
class A
{
int x;
};
class B
{
template<class T> void temp(T* = NULL){}
void test(void);
};
void B::test(void)
{
temp<A>();
};
Still doesn't work.
|
|
|
|
|
Does anyone know of a book or of a website that explains MFC in easy terms ?
I'm pretty much of a begginer in C++ (although i know C very good ).
Anyway, I'm looking for some examples in MFC and their solutions, that will give me a good base to start learning advanced MFC programming.
Thanks
Alessandra
|
|
|
|
|
if you want a site www.codeproject.com and www.cplusplus.com are helpfuls
|
|
|
|
|
Thanks
Alessandra
|
|
|
|
|
You're welcome
|
|
|
|
|
Since much of MFC is an object-oriented wrapper around Windows APIs, I think it's important
to know the basics of Windows programming - windows, messages, etc. MFC then provides a nice
C++ wrapper for that functionality.
Mark
|
|
|
|
|
Mark Salsbery wrote: I think it's important to know the basics of Windows programming
Agreed 100%!
/ravi
|
|
|
|
|
Sure but that's a lot of trouble to go through for a Fish Filet
led mike
|
|
|
|
|
This[^] seems like a nice set of tutorials to help you get started.
But I think you'll find no better site than CodeProject[^] when you have questions or need help or want to dive deeper into the wonders and quagmire of MFC.
/ravi
|
|
|
|
|
|
I'm working on a GUI editor for a video game. The GUI items (buttons, images, etc) are simply a hierarchy of simple rectangle regions.
I need to create a C++ MFC Tool Window that displays the hierarchy. I know what you're thinking "use a tree control". The problem is that:
1) the hierarchy may get very deep; which causes ugly horizontal scrolling.
2) each item needs custom display options to toggle visibility of the item in the main view.
3) It also needs to render additional icons next to the text to show status information. Some status icons might be things like "item has script attached to it", or "item has events attached to it".
4) I need to select multiple items from the control at a time (like a list box)
The closest thing I can relate it to would be Photoshop's Layer View Window. The key difference would be that I need to display the items as a hierarchy.
I implemented a version of this control as a list box and simply inserted space characters for child items to display the hierarchy (based on recursive depth). This worked OK but had all kinds of update issues and bad refreshes, and inaccurate displays of which items were actually "selected". It sucked...
I also couldn't use any of my accelerators that were attached to the main window frame because the tool window had focus.. But that's likely another issue all together..
HELP! Has anyone implemented something like this?
-- modified at 12:40 Friday 9th February, 2007
|
|
|
|
|
Taking each problem separately, you can adjust the indent width with the TVM_SETINDENT message, which may help the display of deeper trees.
If by you mean toggling visiblity, you mean removing an item and its subtree entirely, or just hiding its label and child items? You might be able to get away with just collapsing the item, or you can even remove the entire subtree of necessary, adding it back and redrawing as necessary.
Each tree item can have its own icon. A little "Custom Draw" magic can be used to render additional visual information as well.
Multiple selection can be simulated by using the TVIS_DROPHILITED item style (setting and later checking for it).
There are a few articles here that talk about using a custom TreeView control, as well as one or two ways to use a ListView control as a multi-column tree control.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks for the help!
By the way,
What I meant by visibility is more like the the EYE icon you see in Photoshop, where it acts like a Check Box. If you enable the box, it will cause that layer to be rendered (elsewhere in the main window; not directly related to tree view). If disabled, then that branch of the hierarchy will be ignored when rendering the items in the main window.
ex: GUI navigator
[] = icon / bitmap
# = a check box to determine if the branch should be rendered in the main frame
> = collapsed node
V = expanded node
Y = (optional) item has script assigned to it
Z = (optional) item has mouse/key events that it's listening for
-------------------------------
| Navigator |
-------------------------------
| [#]V ROOT [ ][ ] |
| [#]> CHILD 1 [ ][Z] |
| [#]V CHILD 2 [Y][ ] |
| [ ] SUB-CHILD [Y][Z] |
-------------------------------
I appreciate the help, it definitely gives me a solid direction to take now.
If only I could have done it in ASCII I'd be done by now. hehe.
|
|
|
|
|
TVM_SETINDENT seems to be clamping the results to 15 or larger for some reason. This is not a huge issue as I've decided to write a custom owner draw for the tree; based on the VividTree article. I nudge the RECT region back by a fixed indent; based on the results I get back from GetItemRect() for each item.
TVIS_DROPHILITED worked great! I got it to behave exactly as I intended.
Going the route of Owner-Draw was a bit more of a hassle but it really let me tweak the visuals.
[ question ]
Does TreeCtrl not support double clicking?
<br />
...<br />
afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult);<br />
afx_msg void OnDblClick(NMHDR* pNMHDR, LRESULT* pResult);<br />
<br />
...<br />
ON_NOTIFY_REFLECT(NM_CLICK, OnClick)
ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblClick)
END_MESSAGE_MAP()<br />
Thanks again,
- Ben
|
|
|
|
|
Hello community! I have a little program that I run with another (already existent) program, which I do not have source code to.
I just want to run both programs with one click, so I wonder if there is a command I can add at the top of the main file? Something like:
int main(){
run("game.exe");
... //more code here
if you get my drift.
OK I got it to work with shellexecute BUT I can only open the exe if I have them both in the same folder.
HWND m_hWnd;
ShellExecute(m_hWnd,"open","game.exe","", "", SW_SHOW);
//that works but only if they are both in same folder.
If I provide another directory like:
ShellExecute(m_hWnd,"open","C:\\Program Files\myproj\game.exe","", "", SW_SHOW);
(it is the right directory) it won't work...
-- modified at 13:16 Friday 9th February, 2007
|
|
|
|
|
Maddack wrote: I just want to run both programs with one click, so I wonder if there is a command I can add at the top of the main file? Something like:
Maddack wrote: Perhaps there is a way to do this in windows instead of c++?
Do you mean like a batch file?
The batch command start could help you.
On an console, type help start
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
|
Shellexecute() or CreateProcess()
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
Can you make a project with c++ if yes simply use of Shellexecute /ShellexecuteEx /CreateProcess
|
|
|
|
|
You need to escape all backslashes in string literals - your path to game.exe doesn't do that.
|
|
|
|
|
try this
ShellExecute(m_hWnd,"open","C:\\Program Files\\myproj\\game.exe","", "", SW_SHOW);
Sethuraman.K - Bangalore
|
|
|
|
|
Hello Comunity,
i have an simple SaveAs dialog in my project to save some information in to files!
Ok,but i need some extra controls on this one,
is there any way to modify this standard SaveAs dialog?
E.g. add some new controls to this, button , checkbox, listbox etc.?
Thanks for any help!
regards
break;
|
|
|
|