|
I'm not sure I understand what you want to confirm.
when you click on a tree item, you will have a TVN_SELCHANGED notification ( add an handler for that ), in the handler you will receive the HTREEITEM that is selected.
something like :
void MyTree::OnTreeSelchanged( NMHDR* pNMHDR, LRESULT* pResult )
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
HTREEITEM item = pNMTreeView->itemNew.hItem;
}
if you want to check for a "hardcoded" string, CTreeCtrl::GetItemText( ... ) might be what you want to check for.
otherwise, I'm not certain.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
look at this figure:
----------------- 1
--1-------------- 2
---1。1-------- 3
---1。2-------- 4
---1。3-------- 5
--2-------------- 6
---2。1-------- 7
---2。2-------- 8
---2。3-------- 9
you know when i click the item for example item 4 which is"---1。2--------";
the question is how can i know that i clicked the item is item4 not others by code in my function OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult) ?
that means how to judge the item clicked is the one i want in code.
your hint using GetItemText( ... ) maybe bot work when my item text is put dynamically,for you even not konw the exact text.
路漫漫其修远兮,吾将上下而求索。
|
|
|
|
|
try88 wrote:
...how can i know that i clicked the item is item4 not others by code...
By looking at the NMTREEVIEW structure, specifically the itemNew member.
try88 wrote:
your hint using GetItemText( ... ) maybe bot work when my item text is put dynamically,for you even not konw the exact text.
What? How else are you going to add text if not dynamically? Tree controls are not populated at design/compile time. If an item has text, that text can be retrieved via GetItemText() . Have you looked at the documentation for how this function works?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
HTREEITEM item = pNMTreeView->itemNew.hItem; tells you what item you clicked on.
if you add things dynamically to the tree, you will need to attach some kind of user data to each item ( or leaves ) of the tree with CTreeCtrl::SetItemData to identify it.
besides, your figure it not clear at all; what is the tree data ? what is the item number ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
thank you !!
Maximilien wrote:
SetItemData to identify it
is just what i searching for days! God will bless you!! thank you !!
路漫漫其修远兮,吾将上下而求索。
|
|
|
|
|
I have device driver and I want to write in a file from within the driver.
I am using ZwCreateFile()
ZwWriteFile()
ZwClose() functions.
When I call the InitializeObjectAttributesfunction()
i do not know how should the object name look like.
I mean if my file name is: D:\\status.txt or something like this:
\Device\HarddiskVolume1\status.txt
I want to ask now if these are the functions I should use when writting in a file from the kernel:
Here is a piece of code.
Can someone tell me what I do wrong?
NTSTATUS WriteStatusInFile(
IN PCWSTR FileName,
IN HANDLE hProcessId
)
{
UNICODE_STRING ObjN;
OBJECT_ATTRIBUTES ObjAttrib;
UNICODE_STRING ObjName;
IN HANDLE hFile;
IN IO_STATUS_BLOCK StatBlock,WStatBlock;
RtlInitUnicodeString(&ObjN,L"\\D:\\status.txt");
InitializeObjectAttributes(&ObjAttrib,&ObjN, OBJ_KERNEL_HANDLE , NULL, NULL);
ZwCreateFile(&hFile,
FILE_WRITE_DATA|FILE_APPEND_DATA,
&ObjAttrib,
&StatBlock,
0,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_WRITE,
FILE_CREATE |FILE_OPEN,
FILE_SEQUENTIAL_ONLY,
NULL,
0
);
ZwWriteFile(
hFile,
NULL,
NULL,
NULL,
&WStatBlock,
L"Process Created or Terminated\n",
sizeof("Process Created or Terminated\n"),
NULL,
NULL
);
ZwClose(hFile);
return WStatBlock.Status;
}
Thanks in advance.
gabby
|
|
|
|
|
This is how its done.
Its a code chunk out of an ndis driver but its the same as what you wil want:
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
UNICODE_STRING ObjectName;
RtlInitUnicodeString(&ObjectName, L"\\DosDevices\\C:\\R_NDIS.txt");
InitializeObjectAttributes(&ObjectAttributes,
&ObjectName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = ZwCreateFile( &hfile,
GENERIC_WRITE,
&ObjectAttributes,
&IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
0,
FILE_OVERWRITE_IF,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_ALERT,
NULL,
0);
if(IoStatusBlock.Status != STATUS_SUCCESS)
{
DBGPRINT(ERROR, ("Couldn't create file\n"));
}
else
{
/// write data...
Nunc est bibendum!
|
|
|
|
|
Hi,
I have a CWinApp from where I start a dialog box. In the dialog box I have an Edit box and other controls.
In the Oncreate of dialogbox, I am registering a callback function.
The function say f() to be called is in the same cpp file as the app. The callback procedure is done in a DLL.
I need to set text in the Dialog box's edit box from this function.
the function is written as below:
I tried AfxGetMainWnd() and use GetDlgItemText. but that doesn't work.
Even Messagebox doesn't show-up, same time I don't get errors also
PLEASE GIVE ME A SOLUTION !!!!!!!!!
int
WINAPI
MyNotify( )
{
CWnd CMainWindow;
CWnd *pMainWnd = (CWnd *)AfxGetMainWnd();
CWinApp *pAppWnd = AfxGetApp();
pMainWnd->MessageBox("in call back");
pMainWnd->GetDlgItemText(IDC_EDITCustLog,szCustLogA);
szCustLogA += "\r\n-- in call back --";
pMainWnd->SetDlgItemText(IDC_EDITLog, szCustLogA);
return TRUE;
}
- KK
|
|
|
|
|
Is MyNotify() exported properly?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
MyNotify is ok. It is being called. But if I write MessageBox("Hello"); I get an error, MEssageBoxA does not take one parameter.
I guess this is because MyNotify is not member of CDialog.
I want to do a SetDlgItemText on a edit box in my Dialog.
So, how to access a edit box in a dialog from a function which is not a member of the dialog class ?
If it was a normal function, I could have passed a pointer of Dialog to the function and used it. But, this is a callback function. THe call back portion of it is working fine.
So other than passing a pointer to dialog, how to access a edit box in a dialog from a function which is not a member of the dialog class ?
-KK
- KK
|
|
|
|
|
kk_vp wrote:
But if I write MessageBox("Hello"); I get an error, MEssageBoxA does not take one parameter.
None of the three MessageBox() functions take just one parameter. Perhaps you are wanting to use AfxMessageBox() .
kk_vp wrote:
So other than passing a pointer to dialog, how to access a edit box in a dialog from a function which is not a member of the dialog class ?
Post a message to it. Let the owner of the control handle the actual updating.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I am using MFC. MessageBox("Hello") works.
How to Post a message??
- KK
|
|
|
|
|
kk_vp wrote:
How to Post a message??
Try PostMessage() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Is MyNotify ever being called? Have you set a breakpoint there? Please show the code in which you register the callback.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi,
Instead of giving solution, I have a lot of questions!! to ask you.
1. Possiblity 1: I think your MyNotify() call back function is not called or not set. Have you placed the MyNotify() function inside the your application cpp file.
2. Possiblity 2 : Otherwise, MFC maintains its state (some internal flags) which cannot be accessed by a normal dll. For example, if you want to use MFC inside a win32 dll, you cannot. It should be a MFC extended dll. So consider this possiblities also while to dig into the problem...
3. You have mentioned you are calling the MyNotify()from a dll. Did you export that function?. If it is How did you export a main exe file to a dll?.
If you register your MyNotify() function, you have to give the address of that function, but how did you get the MyFunction address..
One thing you can do is, call a dll function with the notification function address as a parameter, set that address when you register your callback function..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Why not intercept the EN_CHANGE message sent to an edit box and do something about that change.
or EN_UPDATE
gabby
|
|
|
|
|
MyNotify is ok. It is being called. But if I write MessageBox("Hello"); I get an error, MEssageBoxA does not take one parameter.
I guess this is because MyNotify is not member of CDialog.
I want to do a SetDlgItemText on a edit box in my Dialog.
So, how to access a edit box in a dialog from a function which is not a member of the dialog class ?
If it was a normal function, I could have passed a pointer of Dialog to the function and used it. But, this is a callback function. THe call back portion of it is working fine.
So other than passing a pointer to dialog, how to access a edit box in a dialog from a function which is not a member of the dialog class ?
- KK
|
|
|
|
|
kk_vp wrote:
I guess this is because MyNotify is not member of CDialog.
Yeap you are right, the MyNotify function is a global function, so It's calling global MessageBox(...) which take 4 parameter instead of CDialog::MessageBox....
kk_vp wrote:
I want to do a SetDlgItemText on a edit box in my Dialog.
You have to get pointer to the Dialog Box and put the value in the Edit Box!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
You have to get pointer to the Dialog Box and put the value in the Edit Box!
- YES. but how do I pass a pointer to a callback function. This callback was written by somebody else and I have not much idea. Any tutorial on CALLBACK functions that you know of??
- KK
|
|
|
|
|
Is IDC_EDITCustLog item child of your Main Window.. Is it dialog based application?. Where IDC_EDITCustLogis placed?
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Yes. This is a dialog based application. IDC_EDITCustLog is an edit box placed inside the dialog.
- KK
|
|
|
|
|
Hi KK_VP (Whats this yar)??????!!!
One more catch up from my mind..
You told your callback function is called from a dll..
From the callback function you are tring to set the window text.
The problem could be, you might have different thread(Secondary thread..), from where your callback function could be called. To check this, display a message box or trace the currentthreadid() value in your InitInstance() and also in your notification function. If you get different values, you must do the PostThreadMessage to the thread where you have created your dialogs..
Hope the above approach will help you..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Hi,
its wonderful to get HTML out of MIME buffer. I am able to get HTML out of almost all of my MIME buffer but it is failing for some cases.
Here is the MIME buffer where it crashing when I try to use get body from it.I anaysed that it always crash if HTML body starts with <DIV> or <P> tag.
Content-Transfer-Encoding: binary
Content-Type: text/html; charset=ISO-8859-1
<div><STRONG><FONT color=#ff9900>RTF NOT NULL Without attachment Title-099</FONT></STRONG></div>
code:
// hTempFile it contains handle of My MIME buffer file
CFileSystemStream SourceStream(hTempFile);
IMimeDecoderPtr Decoder;
IPersistStreamPtr pPersist;
Decoder->QueryInterface(&pPersist);
pPersist->Load(&SourceStream);
IMimeBodyPtr Body;
Body = Decoder->Body; -----------------------------------> it crashes here even I tried to put try catch block it never catch.
Mentioned MIME buffer comes from Quick Place. Quick Place is able to convert these MIME buffer into HTML correctly.
Is there any validation check for MIME buffer for MIMEsniffer.dll? How to validate the MIME buffer. I tried to put <HTML> </HTML> and <BODY> </BODY> tag to my MIME buffer and passed it to MIMEsniffer.DLL even it gets crashed.
could you help me out ?
Thanks in advance.
Chandan Kumar
VIT infotech
|
|
|
|
|
chandan kumar wrote:
IMimeDecoderPtr Decoder;
Just like that? Shouldn't you be creating an object to instantiate that interface?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi,
its wonderful to get HTML out of MIME buffer. I am able to get HTML out of almost all of my MIME buffer but it is failing for some cases.
Here is the MIME buffer where it crashing when I try to use get body from it.I anaysed that it always crash if HTML body starts with <DIV> or <P> tag.
Content-Transfer-Encoding: binary
Content-Type: text/html; charset=ISO-8859-1
<div><STRONG><FONT color=#ff9900>RTF NOT NULL Without attachment Title-099</FONT></STRONG></div>
code:
// hTempFile it contains handle of My MIME buffer file
CFileSystemStream SourceStream(hTempFile);
IMimeDecoderPtr Decoder;
IPersistStreamPtr pPersist;
Decoder->QueryInterface(&pPersist);
pPersist->Load(&SourceStream);
IMimeBodyPtr Body;
Body = Decoder->Body; -----------------------------------> it crashes here even I tried to put try catch block it never catch.
Mentioned MIME buffer comes from Quick Place. Quick Place is able to convert these MIME buffer into HTML correctly.
Is there any validation check for MIME buffer for MIMEsniffer.dll? How to validate the MIME buffer. I tried to put <HTML> </HTML> and <BODY> </BODY> tag to my MIME buffer and passed it to MIMEsniffer.DLL even it gets crashed.
could you help me out ?
Thanks in advance.
Chandan Kumar
VIT infotech
|
|
|
|