|
|
|
Hi all,
I want in TreeCtrl when i select any child than its corresponding parent is also selected.
so please tell me how can i do this.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
no direct notifications are sent when a check box gets selected/deselected.
Handle the NM_CLICK message which is sent to the parent window of the tree control
{
Get clicked node's flag ( use HitTest())
PostMessage( CUSTOM_MESSAGE, 0, clicked node's HITEM );
}
Define a custom message to handle the checkbox selection/deselection.
LRESULT CheckStateChange(WPARAM wParam, LPARAM lParam)
{
HTREEITEM hItem= (HTREEITEM)lParam;
int nState = m_myTree.GetCheck( hItem );
if( nState == 1 )
{
// loop till hItem = m_Tree.GetParentItem( hItem ) is NULL and set check mark for each parent item
}
if( nState == 0 )
{
// loop till hItem = m_Tree.GetParentItem( hItem ) is NULL and reset check mark for each parent item
}
}
Ajay
|
|
|
|
|
Hi!
I've two un related applications. The first application has a button on it. The second project has to know whether the button in the first application has clicked or not? How to do?
|
|
|
|
|
you need IPC [^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Isn't it possible by adding the first project to the second project's solution?
My requirement is: The first application(GUI)should run fist(It has three buttons low, medium, high). If low button is clicked, the second application has to load some three vehicles(the second project has code to load vehicles), like wise for second button click, it has to load some five vehicles.
|
|
|
|
|
T.RATHA KRISHNAN wrote: Isn't it possible by adding the first project to the second project's solution?
No. Even if they are in the same solution, they are still two different executables. Putting them in the same solution is just a matter of convenience, it doesn't change anything about the functionalities.
|
|
|
|
|
Three suggestions,
1) On the button click of first application, post a user defined window message to second application and handle it accordingly in second application.
2) If you don't like to define a user defined message, utilize WM_COPYDATA and handle it accordingly. This link will be helpful - http://weseetips.com/2008/04/12/wm_copydata-can-be-used-as-simple-ipc-mechanism/[^]
3) Create a named event and the second application should wait for the event in a thread. On button click of first application, signal the event. The second application will be triggered and handle it accordingly.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Thanks for ur reply. I've decided to use the second method "WM_COPYDATA". I've a few doubts regarding the arguments to the "SendData" method.
For pData_i what value should I pass?
For HWND hTargetWindow_i the second application's exe name or what else?
More Over I'm not using MFC. I'm creating window using an external tool.
Should add the first project to the second project's solution if I use this method?
modified on Wednesday, August 13, 2008 2:55 AM
|
|
|
|
|
T.RATHA KRISHNAN wrote: For pData_i what value should I pass?
The WM_COPYDATA is the simple IPC mechanism used to sent a chunk of bytes from one window to another. Well, in the pData_i just pass some string to identify your button event such as "ApplicEvent_ButtonPressed" or something like that.
T.RATHA KRISHNAN wrote: For HWND hTargetWindow_i the second application's exe name or what else?
in your case hTargetWindow_i is the handle of the window in your second application. You can use FindWindow() to find the window by using the window title.
T.RATHA KRISHNAN wrote: More Over I'm not using MFC. I'm creating window using an external tool.
SDK style programming?
T.RATHA KRISHNAN wrote: Should add the first project to the second project's solution if I use this method?
Not necessary. If you insert both project to same solution, it will be easier to refer. You can avoid switching of windows. Well, you need two Visual Studio instances to debug both at same time.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
If you do messaging you bette use a message ID from RegisterMessage.
Greetings from Germany
|
|
|
|
|
Hi all,
i have made a dialog based application in vc2005.
i want to open help file when we press f1 button...
How can i do this?
Thanks in advance
|
|
|
|
|
Basically you've to handle the WM_HELP message. When you press F1 the WM_HELP message will be posted to your window.
Since you are using mfc, handling it in MFC way will be more easier. Add ON_WM_HELPINFO() to message map and add implement OnHelpInfo() in your dialog. For instance,
BEGIN_MESSAGE_MAP(CYourDialog, CDialog)
...
ON_WM_HELPINFO()
END_MESSAGE_MAP()
BOOL CYourDialog::OnHelpInfo( HELPINFO* HelpInfo)
{
return TRUE;
}
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi,
Could anyone please tell me the maximum size of data that can be copied to clipboard?
Thanks,
Divya
|
|
|
|
|
I have a project on VC++ 6.0, the exe file generated out of that was 5 MB,But after conversion to VS2005 it's now 16 MB.what may be the reason? Any thing else is required to reduce the file size.
Regards,
KDevloper
|
|
|
|
|
|
Hey jijo,
I have already followed the way it's there in your blog, But no it's not helping.. any other idea.
Thanks&Regards,
KDevloper
|
|
|
|
|
"disable Incremental Linking" doesn't make any difference? I hope you've cleaned and rebuild your project. I've tried it in a sample visual studio 2005 project and i can see good result. Please check once again!
Well, the MFC libraries are statically linked? that can increase your exe size.
kDevloper wrote: I have already followed the way it's there in your blog, But no it's not helping.. any other idea.
Oooh! You already read that one?
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Yes, am cleaning and rebuilding this 500 bunch of files from last evening.. but i guess the "disable Incremental Linking" and code generation property change helped me to gte out of the problem.. ok thanks.
U r posts in the blog is really useful.
Regards,
KDevloper.
|
|
|
|
|
kDevloper wrote: U r posts in the blog is really useful.
Thanks a lot for those kind words.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
|
ok.. will check it out.
Thanks &Regards,
KDevloper
|
|
|
|
|
I am new to VC++ programming and have coded for the first time trying to understand Windows messaging. (I am more used to the good old days of Borland's Turbo C++ 3.0)
My question is about structures.. In the snippet below I have defined my structure as such.
In this snippet I have declared the structure in the Window Process DlgProc as static TONE tsTone; which now works for me!! I previously had it declared as just TONE tsTone; .
If I do not declare the structure as static, after populating the members in the IDC_ONOFF: message when the Windows Process is called again, the structure reference in MM_WOM_OPEN: message has rubbish member values and has a different reference address.
My question is - given the struct of TONE tsTone; is declared within the scope of DlgProc why does the structure appear to be volatile and given a new reference address when a different Windows message is processed? If I am using variables that are spread throughout Windows Messages (but still within the scope of the WinProc), should all variables be declared static?
P.S. some reading reference would be very handy if you have it so you don't have to re-invent the wheel.
Aaron.
typedef struct {
int itoneEncoding;
double dtoneLeadin;
double dtoneLength;
int iBuffersize;
}TONE, * PTONE;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
<<SNIP>>
}
BOOL FillBuffer (PBYTE pBuffer, TCHAR * pszToneCode, PTONE tsTone)
{
int iBuffer;
<< SNIP >>
iBuffer = tsTone->iBuffersize;
for(icTone = 0; icTone < 5; icTone++)
{
<< SNIP >>
else
return FALSE;
<< SNIP >>
return TRUE;
}
BOOL CALLBACK DlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
<<SNIP >>
static TONE tsTone;
switch (message)
{
<< SNIP >>
case IDC_ONOFF:
tsTone.itoneEncoding = iEncoding;
tsTone.dtoneLeadin = GetDlgItemInt(hwnd, IDC_EDIT_LEADIN, NULL ,FALSE);
tsTone.dtoneLength = GetDlgItemInt(hwnd, IDC_EDIT_TONELENGTH, NULL ,FALSE);
tsTone.iBuffersize = (int)(SAMPLE_RATE * (tsTone.dtoneLength/1000)*5);
<<SNIP>>
case MM_WOM_OPEN:
SetDlgItemText (hwnd, IDC_ONOFF, TEXT ("Turn Off")) ;
GetDlgItemText (hwnd, IDC_TONECODE, szToneCode, 6) ;
if(!FillBuffer (pBuffer1, szToneCode, &tsTone))
<<SNIP>>
case MM_WOM_DONE:
<<SNIP>>
case WM_SYSCOMMAND:
switch (wParam)
<<SNIP>>
return TRUE ;
}
break ;
}
return FALSE ;
}
|
|
|
|
|
Aaron.Morrison wrote: In this snippet I have declared the structure in the Window Process DlgProc as static TONE tsTone; which now works for me!! I previously had it declared as just TONE tsTone;.
While declaring your structure as TONE tsTone; the structure will be allocated on stack. Since stack will be recreated at different locations during each function call, Local variables on stack are not Persistent between function calls. And local variables will be deleted when the function returns.
if you declare the stack variable as static, it will be initialized during the first call to that function and persists between function calls. They won't be deleted when function returns. For more info, read this - http://www.cprogramming.com/tutorial/statickeyword.html[^]
Aaron.Morrison wrote: should all variables be declared static?
Other possible ways are -
1) You can keep your structure as global.
2) You can create a singleton class to keep the Persistent data and use it (Recommended).
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|