|
Hi all. I'm a new C++ programmer. Wonder if anyone know how to draw a tree graph with C++? without calling packaged libraries.
|
|
|
|
|
amica wrote:
without calling packaged libraries.
This means you want to write all the code yourself (not that I know what you intend with a packaged library). Since you already told us you don't know how, do you expect us to write the code for you, or do I misunderstand your definition of packaged?
|
|
|
|
|
Well, I wanted some ideas to do it myself. Calling plotting routines in any visual tools doesn't give me the experience of how to put the tree out on the paper. I actually intend to put the tree result out in SVG.
|
|
|
|
|
tree is simple in concept and complex in implementation... it's just a bunch of nodes and links. There'll be a lot of recursion and depending on what feature u wish to support... the most basic config is to create a bunch of nodes, each "pointing" to each other.
i built one sometime ago. lost it now and the reason i built it is that i couldnt find one for free that's ANSI compliant - i needed something for unix box as well as for Windows.
anyway, u do know how to build a link list do u? you tree class prolly look like this:
class CNode
{
private:
CNode();
void * pNext; //point to "next" node
void * pPrev; //point to "prev" node
void * pParent; //point to yr daddy
void * pFirstChild; //point to amica junior
...
..
public:
int AddChild();
int RemoveChild(int nIndex);
int SetParent();
int SetPrev(); //Just remember when u attach a Node, u're forming a relationship BETWEEN TWO nodes. so, the pNext and pPrev will need to be changed for BOTH NODES involved.
int SetNext();
...
...
};
class CTree
{
private:
void * pRootNode;
public:
... whatever u'd like to implement to help yr client to access the nodes...
GetRoot();
GetNode(int nLevelID, int nItem);
};
Good luck. It's my second good deed today, time for bed before sunrise =)
norm
|
|
|
|
|
A newsteler I got today about Intel C++ Compiler.Does any of you even used that?
|
|
|
|
|
I have an application to which I need to add a monitor thread for testing things in debug mode.
I need to start the thread when the test is started and it needs check if a message box or dialog is popped up and if so close it.
When the test is complete the thread is shut down again.
What is the simplest way to achieve this? Sample code would be most helpful.
Thanks in advance
Happy programming!!
|
|
|
|
|
What is the best way of upgrading an application via the web? I would prefer it to be included as a dll instead of a stand alone exe. My thought would be to check a dat file for a version change and a url to the upgrade. How would I close the running app to replace it with a newer version? How could I control who had access to download upgrades? Any sudo code would be nice thanks in advance.
All ideas are excepted, thanks.
Darroll
|
|
|
|
|
Imho, there's probably no "best" way to do this, but there certainly are a number of alternatives. You should pick the one that works best for your type of app. Here are a couple off the top of my head. I'm sure other people could come up with smarter ideas.- Load all your DLLs explicitly (using
LoadLibrary() ). This lets you replace DLLs on the fly. Your main app would be the driver for the upgrade task, allowing the user to upgrade without exiting the app. Imho, this is likely to be a lot of work, since you have to design your app from the start to load its behavior from DLLs, and have very little business logic within the app itself.
- Spawn an external upgrader app that only knows how to check for a newer version, shutdown the current version, upgrade the app, and restart the upgraded version. This is relatively easy to do and puts almost no constraints on the design of your app.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
This is weird, I've never seen this before and can't track down any documentation on what exactly it means, but a test application that I'm working on always states this in the debugger output window when I close it:
The thread 'Win32 Thread' (0x5f0) has exited with code 2 (0x2).<br />
The thread 'Win32 Thread' (0x65c) has exited with code 2 (0x2).<br />
The thread 'Win32 Thread' (0x3a4) has exited with code 2 (0x2).<br />
The thread 'Win32 Thread' (0x3f0) has exited with code 2 (0x2).<br />
The program '[1260] QBTEST.exe: Native' has exited with code 2 (0x2).
There are no errors reported anywhere in the program or above the lines above in the output window and it's pretty straightforward, instantiates a com component works with it, releases it properly and exits. Something I've done thousands of times before with other applications.
Anyone know what this is?
|
|
|
|
|
Every thread and process sets a DWORD when it terminates, called its exit code. Back in the DOS days, commands like "copy" would set their code to indicate success/failure, which batch files could then test with ERRORLEVEL.
However, there's no hard-and-fast rule about what the exit code means. In fact, a thread's code is ignored most of the time, because it's just not important.
So it's nothing to worry about.
--Mike--
"Adventure. Excitement. A Jedi craves not these things."
-- Silent Bob
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Good news! Thank you.
- John
|
|
|
|
|
I want to write characters to a CScrollView window one character at a time, much like CEditView. I've seen the MSDN docs on CDC and text related functions, but they work on entire strings. Given the x/y position and the font, how to display just one character? Thanks
|
|
|
|
|
If all you want to do is display text, why not just use a CEditView?
Software Zen: delete this;
|
|
|
|
|
How do I detect if a child control is inside the clipping area of current device context?
I have a ownerdraw listbox with two transparent buttons as child controls. In my listbox DrawItem() handler I need to manually trigger a child controls update in some case. So I like to test if a child window area is inside the clipping area of my pDC.
thanks for some help!
|
|
|
|
|
You can use this code in order to get the current clipping rgn that has been initialized from ::BeginPaint:
HRGN hRgn = ::CreateRectRgn(0,0,0,0);
::GetRandomRgn(hdc, hRgn, SYSRGN);
Then you will need to create a rgn from your child window and you can do an intersection test to determine if your child needs to be repainted. At that point you can force a repaint of your child window with a call to ::RedrawWindow with the interected region.
I have written two articles that may help you, the first is about device contexts and clipping regions and the other is a general article about regions.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
thanks, the article helps a lot for my understanding!
I feel good to find a solution for my problem.
|
|
|
|
|
Paul Watt wrote:
Then you will need to create a rgn from your child window and you can do an intersection test to determine if your child needs to be repainted. At that point you can force a repaint of your child window with a call to ::RedrawWindow with the interected region.
after playing with some ideas... I use this code now:
BOOL IsClientVisible(CDC* pParentDC, CWnd* pClientWnd)
{
ASSERT(pParentDC);
ASSERT(pClientWnd);
CRect rectClient;
pClientWnd->GetWindowRect(rectClient);
ScreenToClient(&rectClient);
return pParentDC->RectVisible(rectClient);
}
|
|
|
|
|
I want to create a Modal Dialog and be in control of it's position in the app.
Or even be able to dynamically change it's position.
Is this posible?
George W
Software Developer
www.zsystems.ca
|
|
|
|
|
You can do that in two ways, the easy way is to have your dialog call your app and allow your app to determine if it needs to move your dialog.
The hard way may be a lot of work, but if this solution does not work, let me know and I will explain the other method.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
hi,
just wondering,
dlg.SetWindowPos()
can u jsut call SetWindowPos in response to event - say OnTimer - to adjust the dialog position?
i can imagine a situation in which u create a modal/modeless dlg and u wish the dialog to stay within the boundary of its view.
in this scenario, do u need to create your own event - for the dialog class? how can u implement this? how can u check that the child dialog is out of place (out-of-predefined boundary) and the fire an even and thru message map i suppose we can handle the situation appropriately??
thanks!
norm
|
|
|
|
|
I tried SetWindowPos() but it ASSERTS.
I was thinking that because I am calling DoModal(), I have lost control of the thing because MFC has taken over. Obviously, any attempts to adjust the position before DoModal() will ASSERT because the dialog window has yet to be created.
Any calls after DoModal() is pointless because MFC is in control.
I am trying a few different things right now.
IGeorgeI
George W
Software Developer
www.zsystems.ca
|
|
|
|
|
hey there,
[QUOTE FROM CODE GURU]
u can do that by adding the virtual function pretranslatemessage
Eg:-
BOOL CUrDlg::PreTranslateMessage(MSG* pMsg)
{
if((pMsg->message == WM_KEYDOWN) )
{
if(GetFocus()->GetSafeHwnd() == GetDlgItem(IDC_UR_EDITCTL_ID)->GetSafeHwnd())
//necessary action
}
return CDialog::PreTranslateMessage(pMsg);
}
good luck =)
Norman
norm
|
|
|
|
|
Does anyone has an example on how to cancel a process? Like when the user press the Cancel button.
I tried _endthread() but I get 1st chance exception errors... What is the proper way?
Thanks!
|
|
|
|
|
I just used return; in the thread function and it seems to work... is this the proper way to do it?
|
|
|
|
|
_beginthread begins a thread of execution, not a process, second, it's evil, dump it and use _beginthreadex that have a appropriate Thread Information block(TIB) to properly clean the resources consumed by the thread.
Similarly the _endthread should not be used , use _endthreadex ... but it shouldn't use this either , the threads should exit for themselfs . You should create a event or binary semaphore (depending of what you want to achieve) and signal it to the thread that you want to cancel,then on the target thread that is expecting on a WaitforMultipleObjects(or similar), you catch the signed event(action) , clean up the resources , if you need to, and do a exit command(return ...) or exit simply by failling over the WaitFor ... loop ..
Cheers,Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9
Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech
|
|
|
|