|
This is re-post, as I really could do with some help..
Hi.
I have a simple console app which I use to CreateProcess() other console apps with re-directed output streams so that I can get hold of their output with PeekNamedPipe(). I have just noticed, by accident (which does not say much for my intensive testing) that in the output from the DOS tree command, the nice ASCII angle and bar characters are encoded incorrectly (I think with the default windows encoding). My App is built using MBCS which I understand is OK for ASCII, what do I need to do to get an output identical to the command-line invocation of TREE.
Any thoughts are much appreciated.
James.
|
|
|
|
|
Hi, Mark directed me to the MSDN section about scrollbars this morning which helped a lot, but I still have one problem that I can't seem to solve:
Once again I'm using VC++ with MFC, and I have a CScrollBar that I want to use to scroll some custom controls.
I don't want to use the dialog's "built-in" scrollbar because it isn't in the right place and I have lots of other bits of data there, so I have a stand-alone CScrollBar control that I have mapped through DDX_Control to my dialog.
Since my scrollbar is stand-alone I had to subclass it in order to catch the WM_VSCROLL messages sent to its window when the bar is moved. This all works fine BUT ONLY when I have the scroll bar's style set as WM_VSCROLL. The style SHOULD be SBS_VERT, but when I make the style SBS_VERT instead of WM_VSCROLL, I no longer get any WM_VSCROLL messages in my subclassed process. What could I be doing wrong???
Also on a side note, it seems pretty ridiculous that I have to either subclass the control or overload it and handle OnVScroll explicitly to get the scroll bar to function. Is there a better way?
Thanks!
KR
|
|
|
|
|
You can catch the WM_VSCROLL message in the parent of
the scrollbar control. There's no reason to subclass the
control.
KellyR wrote: ONLY when I have the scroll bar's style set as WM_VSCROLL
WM_VSCROLL is a message, not a style, so it shouldn't be used as a style
If you don't specify SBS_VERT as a style, then the default is SBS_HORZ.
I tested this real quick - Here's all I did:
1) Added a scrollbar control (vertical) to a dialog
2) Right clicked the control and added a control variable (to the dialog's class)
3) Added a WM_VSCROLL handler to the dialog class.
Clicking on the scrollbar control sends a WM_VSCROLL to the parent
as expected.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
That's weird, that's the first thing I tried earlier today and it didn't work. I must have done something wrong before because it seems to work now. I thought it was stupid to have to subclass the thing...
Ok, all set, thanks!
KR
|
|
|
|
|
firstly I am unable to append the file in question,
so I load the contents of the file, into an array.
then reopen to write the loaded contents, plus
what I want to append, (from the dialogs edit box).
which works fine, everything is written.
How ever, if I enter some more text, and press ok, however a many of times,
the original contents is written, and the last record enterd is only shown.
for example, the file contents is:
1
2
I enter 3 in the edit box(press ok) then 4
and end the program.
the file contents
is
1
2
4
the update declaration is set to true 'update(true)';
how ever if I set update to false.
the file contents is
1
2
-> only
I am not sure if the file contents have been reloaded and rewritten or not
but changing the update to false, I do not know if this is in any relation
to the program failing to write the subsequent messages
has any body got a clue why this is not working.
perhaps my understanging of how dialogs work is in question.
thanks in advance
Simon
|
|
|
|
|
I am working on an iTunes plugin using their own SDK the only thing I have changed is adding two MessageBoxes. iTunes sends stream information to a function in the plugin where I am able to access it. Here is the code.
case kVisualPluginPlayMessage:
if (messageInfo->u.playMessage.trackInfo != nil)
visualPluginData->trackInfo = *messageInfo->u.playMessage.trackInfoUnicode;
else
MyMemClear(&visualPluginData->trackInfo,sizeof(visualPluginData->trackInfo));
if (messageInfo->u.playMessage.streamInfo != nil)
visualPluginData->streamInfo = *messageInfo->u.playMessage.streamInfoUnicode;
else
MyMemClear(&visualPluginData->streamInfo,sizeof(visualPluginData->streamInfo));
//MessageBox(NULL, visualPluginData->streamInfo.streamTitle, "Stream Title 1", NULL);
MessageBox(NULL, visualPluginData->streamInfo.streamTitle, "Stream Title 2", NULL);
visualPluginData->playing = true;
break;
streamTitle is an str255 variable passed on by iTunes. Now, if I run it like it is it will display nothing for streamTitle. If I run it without the first MessageBox uncommented it will display nothing for streamTitle the first time, but the second MessageBox will have information in it. This is driving me insane haha and any help would be greatly appreciated.
|
|
|
|
|
Can anyone tell me the API I can use so that while my app is running it doesn't allow the OS to go into sleep or suspend mode? What must I do.
Thanks!
|
|
|
|
|
Assuming you're developing on Windows, take a look at the WM_POWERBROADCAST message (docs here) which is sent to all top-level window procedures when a power state is about to change. To prevent Windows going into standby/sleep mode, check whether the wParam is PBT_APMQUERYSUSPEND , and if so, return BROADCAST_QUERY_DENY when processing this message (Win 2k3, Win XP and Win 2k).
However, for Windows Vista, use the SetThreadExecutionState() function (docs here), which can prevent the system entering sleep mode. It is also supported in Win XP and Win 2k Pro.
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
Thanks for the pointers. I did end up using SetThreadExecutionState() as I really didn't need the fine control WndProc and it's power handling functionality offered. Nice and easy.
Cheers!
|
|
|
|
|
I have a TreeView with 8 root nodes in which I want to select / deselect all decedent nodes based on any given node I select / deselect.
I have tried overriding the OnNotify, but have been unsuccessful in trying to get the behavior I want. Currently, the OnNotify only seems to work on the first root node... none of the other sibling root nodes seem to trip the OnNotify. The other problem I'm having is on the one root node that does respond via OnNotify, I cannot traverse its branches to select / deselect node paths I want ignored. All decendant nodes of this one root node only react when the root node is selected / deselected.
This is what I have on the OnNotify:
BOOL CViewFilter::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
if (wParam == IDC_TREE1)
{
HTREEITEM hItem = m_filterTreeCtrl.GetSelectedItem();
if ((hItem != 0) && (m_filterTreeCtrl.GetCheck(hItem) == 0))
{
SetDecendentNodesOff(hItem);
}
else if ((hItem != 0) && (m_filterTreeCtrl.GetCheck(hItem) == 1))
{
SetDecendentNodesOn(hItem);
}
}
return CDialog::OnNotify(wParam, lParam, pResult);
}
Any help would be greatly appreciated.
modified on Thursday, September 4, 2008 1:56 PM
|
|
|
|
|
I read your post a couple times and I have no idea what you are trying to do. Have you read any beginner material for working with windows tree controls like this CodeProject article[^]
That's only one, there are tens of CP articles using the Tree Control
led mike
|
|
|
|
|
I am using a tree view with 16,384 nodes (2048 nodes per root node). I'm trying to allow a user to select or deselect a node anywhere on the tree view such that when a node is selected or deselected, all of its children nodes would mirror that selection.
|
|
|
|
|
There is a lot of notifications sent by a tree control.
Do you really want your code to execute on every one of them?
Also, what are you doing with the item check state, and how does
that apply to the selected item?
Tree View Controls[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I originally tried doing a message map of the OnNotify that I saw elsewhere through googling, but there does not seem to be a notification appropriate for what I want to do.
I was using item check state to see if the node which has the user's focus was checked or not.
The idea was that once a user clicks on a node within the tree view, OnNotify would fire off and it would check to see if the node was selected or not. Depending on its state, I would either select or deselect all decedent nodes from the node the user selected.
|
|
|
|
|
What about something like this:
BOOL CViewFilter::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
if (wParam == IDC_TREE1)
{
NMHDR *pHdr = (NMHDR *)lParam;
if (pHdr->code == TVN_SELCHANGED)
{
LPNMTREEVIEW pNMTreeView = (LPNMTREEVIEW)lParam;
if (pNMTreeView->itemNew.hItem)
{
if (m_filterTreeCtrl.GetCheck(pNMTreeView->itemNew.hItem))
{
SetDecendentNodesOn(pNMTreeView->itemNew.hItem);
}
else
{
SetDecendentNodesOff(pNMTreeView->itemNew.hItem);
}
}
return TRUE;
}
}
return CDialog::OnNotify(wParam, lParam, pResult);
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It only works on the very first mouse click for the first root node only. Decendent nodes nor any of the other root nodes have any effect on the OnNotify.
After the first mouse click to either select / deselect the 1st root node, that root node then behaves like the other root nodes.
|
|
|
|
|
Do you call SetCheck anywhere? How do the items get their check state set?
What's happening in your SetDecendentNodes functions?
Have you put a breakpoint in the OnNotify? Are you getting
notifications for all item selections?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I do not call SetCheck.
The nodes get their check state set whenever the user clicks on the node's box to check or uncheck the node.
|
|
|
|
|
Ohhh....
Maybe you want the TVN_ITEMCHANGED notification instead of TVN_SELCHANGED
BOOL CViewFilter::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
if (wParam == IDC_TREE1)
{
NMHDR *pHdr = (NMHDR *)lParam;
if (pHdr->code == TVN_ITEMCHANGED)
{
NMTVITEMCHANGE *pNMTVItemChange = (NMTVITEMCHANGE *)lParam;
if (pNMTVItemChange->hItem)
{
if (m_filterTreeCtrl.GetCheck(pNMTreeView->itemNew.hItem))
{
SetDecendentNodesOn(pNMTVItemChange->hItem);
}
else
{
SetDecendentNodesOff(pNMTVItemChange->hItem);
}
}
return TRUE;
}
}
return CDialog::OnNotify(wParam, lParam, pResult);
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yeah, that was one I had tried using before but the problem is you need Windows Vista to use it. I'm running on XP Pro.
|
|
|
|
|
Stuck At Zero wrote: the problem is you need Windows Vista to use it
There's other OSs?
Do you get any notification in XP when you check/uncheck an item?
If so, what is the code?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
I really thought it was available on XP.
The macro is wrapped in "#if (_WIN32_IE >= 0x0600)"
which seems to indicate a common controls version 6
or better feature.
If you define _WIN32_IE to something >= 0x0600 does
it work on XP? I don't have a handy XP machine to test on.
Also, have you tried (in the debugger)to see if there's any
notification sent when you change the check state? I'm interested
in what notification code it is if there is one.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I couldn't figure out how to filter out the other things OnNotify would trigger, but I believe part of my problem seems to be that the hItem is what the TreeView has as a keyboard highlighted region rather than the actual node clicked on by mouse.
Do you have any ideas as to change hItem to reflect what is actually clicked on by the mouse and thus ignore the keyboard rectangular region that highlights the 1st root node or changes if I use my keyboard to move it around?
In other words,
HTREEITEM hItem = m_filterTreeCtrl.GetSelectedItem();
Is not with respect to the node I click on with my mouse.
|
|
|
|
|
Hi, I'm using VC++ with MFC.
I have a CScrollBar in my program which is supposed to perform various functions when it is moved.
How can I tell when the user has clicked on the scrollbar and moved it up and down? I thought it might just be EN_CHANGE but this does not seem to work.
I am setting up all of the scroll bar's parameters using SetScrollInfo, which does seem to work, but I cannot tell when the bar is moved and when it IS moved, it does not seem to "stick" at its new position, it just returns to the "nPos" that I initially set it to in SetScrollInfo.
KR
|
|
|
|