|
How can I get Hyperlinks into a CTreeCtrl?
I need individual items of the tree to function and look like hyperlinks.
Thank you,
XP
|
|
|
|
|
you probably won't like my answer
you can add the normal, non-linked url text to give the tree items the propersize, then cycle through them and get each of their rect bounds for the ones you want to hyperlink, then make an instance of 1 Subclassed CStatic over each TREEITEM bounds rect. (CStatic subclassed with the mouseover(trackmouseevent) and cusor change, + notify OnPressed + MAPPED function in parent, to the parent for the link)
for (int i=0; i
|
|
|
|
|
Better find an example of a custom-draw treeview control and customize it to display blue underlined text. To make the mouse cursor behaving as on hyperlinks you'll need to invent detection of where the cursor resides at each moment it is under the control (there is a simple WinAPI function that reports if the mouse cursor is under the text, or icons, or white space) and use a timer to detect OnMouseLeave. 2-3 day of work, probably
--
Best Regards,
Andrew
|
|
|
|
|
Hi all
why does this mean?
(CTestDoc*)m_pDocument;
Thanks
|
|
|
|
|
just like that ? no context ?
it simply means that the m_pDocument (that must be a CDocument class) is casted into a CTestDoc class.
meaning that the variable will be "seen" as a CTestDoc instead of the generic CDocument base class.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Thanks
Why? it is (CTestDoc*)m_pDocument; not CTestDoc* m_pDocument;
|
|
|
|
|
Because it's not a variable definition, it's a cast.
|
|
|
|
|
the first one is operation called 'casting' - looking to the same thing in a different way - e.g. when one object is derived from some base and you have a pointer to that object, you can cast it to be the pointer to the base and use methods from the base class, but still using the same instance of object.
The second constructs creates a new uninitialized pointer to CTestDoc.
|
|
|
|
|
(CTestDoc*)m_pDocument; //this is type cast
CTestDoc* m_pDocument; //this declares a variable
Consider this:
void* GetDocument(); //function declaration -> notice it returns a void*
CTestDoc* m_pDocument; //declare a variable of type CTestDoc*
m_pDocument = (CTestDoc*) GetDocument(); //Call the function. Notice how the result is cast using (CTestDoc*). A void* would not fit into the m_pDocument variable of type CTestDoc*. Hence it is cast using (CTestDoc*).
XP
|
|
|
|
|
Hi all
is this Casting?
(void *) TNptr;
|
|
|
|
|
yes, it casts TNptr into a void* pointer ( generic pointer).
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
It may help to point out that casting usually occurs on the right hand side of the assignment operator (=). Casting means "make this variable look like...". So if the compiler encountered statements like this, it would complain about the invalid assignment to pFoo :
CBar aBarObject;
CFoo* pFoo = &aBarObject;
But if you made &aBarObject look like a pointer to a CFoo (for the purpose of the assignment), all would be well. As in:
CBar aBarObject;
CFoo* pFoo = (CFoo *) &aBarObject;
Hope this helps.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I’m writing telnet program. All chars I get from client socket (except telnet commands of course) I pass to command.com/cmd.exe (running in separate process).
Problem is: when client passes “regedit.exe” for instance – it is run on server machine ( !!) which is not what I intended …..
So the question is: HOW to protect from running GUI programs by my command interpreter?
(I’m pretty sure it can be done ... in pure DOS you can see the message “This program can not be run in DOS mode … this is what I want)
Please HELP
|
|
|
|
|
You mean you're writing a telnet _server_.
But anyway, that's not necessarily a bad thing to run windows apps. For remote administration I find it useful to run, for example, "shutdown.exe /l /r /c /y /t:60" from the NT Reskit via telnet or remote shell, which I believe is a non-console app.
|
|
|
|
|
No, it cannot be done, at least not in a simple way.
There is no "pure DOS" in the modern Windows. cdm.exe executes both Windows and DOS programs.
As far as I know the only way to distinguish between a Win32 console (DOS-like) and Win32 GUI executable is to follow its WinAPI function calls AFTER it was executed or to perform a kind of reverse engineering to know which DLLs and functions supposed to be used by this executable.
Another way (not suitable but still) is to enumerate all windows in the executed process and detect the console window.
--
Best Regards,
Andrew
|
|
|
|
|
If you have control over which programs are run (ie. it's not by cmd.exe ), then you can read the subsystem from the .EXE file header to determine if it's a GUI program or a console program before you run it. I don't have time to go into the specifics here, but look up the PE file format on MSDN.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hello, everyone!
I find even if I use signal(SIGCLD,SIG_IGN), I can not prevent
child process from becoming zombie process. I have used ps -aux
to check the result.
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
pid_t pid;
signal(SIGCLD,SIG_IGN);
pid = fork();
if(pid)
{
sleep(20); // parent sleep
}
else //child exit
{
exit(1);
}
return 1;
}
Can anyone help?
Thanks in advance,
George
|
|
|
|
|
The result of signal (SIGCLD, SIG_IGN) varies depending on the system. A better solution is to use 'sigaction' with the SA_NOCLDWAIT flag - this stops a child sending the SIGCLD signal in the first place, and works on all systems (as far as Im aware). 'sigaction' is also more preferred to signal, so its worth looking into it more
|
|
|
|
|
Thanks, Johnny buddy!
Can 'sigaction' also prevent a child process from becoming zombie process?
Can you show me a simple example?
regards,
George
|
|
|
|
|
Yes, the SA_NOCLDSTOP flag means that no signal will be raised by the child when it stops, and this should be consistent across different flavours of Unix (check the man page to be sure - it should have been in Linux for several years now)
Its more work to setup, but its a lot more powerful version of signal. You can use it like this:
sigaction sig;<br />
<br />
sigemptyset (&sig);<br />
sig.sa_flags = SA_NOCLDSTOP;<br />
sig.sa_handler = SIG_IGN;<br />
<br />
sigaction (SIGCHLD, &sig, NULL);
|
|
|
|
|
Thanks, Johnny buddy!
I have tried your code, but it does not work. Here is all my sample
code,
Source code:
--------
#include <signal.h>
#include <sys types.h="">
#include <unistd.h>
int main(void)
{
struct sigaction sig;
pid_t pid;
sigemptyset (&sig);
sig.sa_flags = SA_NOCLDSTOP;
sig.sa_handler = SIG_IGN;
sigaction (SIGCHLD, &sig, NULL);
//signal(SIGCLD,SIG_IGN);
pid = fork();
if(pid)
{
sleep(20); // parent sleep
}
else //child exit
{
exit(1);
}
return 1;
}
--------
Here is what I noticed from ps - aux during the running time of the process,
Output:
--------
root 10914 0.0 0.1 1372 280 pts/0 S 19:47 0:00 ./SigZombie
root 10915 0.0 0.0 0 0 pts/0 Z 19:47 0:00 [SigZombie
|
|
|
|
|
The above will work on Solaris, but I have not tried it on Linux. Rather than go to all this hassle of trying to avoid dealing with the SIGCHLD I think the easiest thing is going to be actually handle the signal and call waitpid on the child. Not only will this stop zombies, but its the cleanest and most portable, and you can get all sorts of information back from the child (esp if you use sigaction).
|
|
|
|
|
Thanks, for your advice Johnny buddy!
Thanks, Johnny buddy!
What do you mean "will work"? Do you mean you can not see "defunc" process from "ps -aux"?
I have referenced some materials, and write a sample from your idea, but it does not work. (still can see "defunc" process from "ps -aux")
Source Code:
--------
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
struct sigaction sig;
pid_t pid;
sigemptyset (&sig.sa_mask);
sig.sa_flags = SA_NOCLDSTOP;
sig.sa_handler = SIG_IGN;
sigaction (SIGCHLD, &sig, NULL);
//signal(SIGCLD,SIG_IGN);
pid = fork();
if(pid)
{
sleep(20); // parent sleep
}
else //child exit
{
exit(1);
}
return 1;
}
--------
Can you help?
regards,
George
|
|
|
|
|
hi there..
thanks for your time firstly..
i am having a strange problem in the invoke of my IDispatch..
This method is called from the get property of an aX control.
When i call this get method, i dont seem to get any return vaule in the pvarresult variable..
any suggestions..
here is the method:
double CControl:: GetNumber(long nRow, long nCol)
{
DISPPARAMS DispParam1;
EXCEPINFO excep;
UINT nArgErr;
VARIANT pVarResult;
double temp;
DispParam1.cArgs = 2; //number of arguments
DispParam1.cNamedArgs = 0;// Number of named arguments.
DispParam1.rgvarg = new VARIANTARG[2];
DispParam1.rgvarg->vt = VT_ARRAY;
DispParam1.rgvarg[1].vt = VT_I4;
DispParam1.rgvarg[1].lVal = nRow;
DispParam1.rgvarg[0].vt = VT_I4;
DispParam1.rgvarg[0].lVal = nCol;
IImpl::Invoke(DISPID_Number , IID_NULL , 0 , DISPATCH_PROPERTYGET, &DispParam1, &pVarResult , &excep, &nArgErr);
temp = pVarResult.dblVal;
//delete [] DispParam1.rgvarg;
return temp;
}
|
|
|
|
|
try to VariantInit the result variant.
VariantInit( &pVarResult );
this can help (and if not, it's anyway better)
|
|
|
|