|
Just replace your resource list box by a static box (IDC_STATIC_LIST, "VISIBLE" = false),
then create a member list box in the OnInitDialog() function
by usage of the client position of the IDC_STATIC_LIST, current resource styles,
and the (passed in dialog constructor) multiselection flag
(Do not destroy any child explicitly)
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
Hi developers,
I want to handle TVM_DELETE or TVN_DELTEITEM from a custom tree control in other file( which is derived from CFormView ). From tree control, I am trying to send
<pre> SendMessage(TVM_DELETEITEM, WPARAM(0), LPARAM(hItem));
I have handled this msg in view file like this
<pre> ON_MESSAGE(TVM_DELETEITEM, OnTvmDeleteItem )
but it simply delete the item and doesn't caught at OnTvmDeleteItem().
I have also tried to send TVN_DELTEITEM with ON_NOTIFY_MESSAGE(), but still it doesn't work.
Pls help me out.
Thanks.
|
|
|
|
|
Amrit Agr wrote: I want to handle TVM_DELETE or TVN_DELTEITEM from a custom tree control in other file( which is derived from CFormView ). What do you mean by that? You want to give the implementation of the handlers for those notifications in a different file than the one that hosts your CFormView derivative's implementation?
Amrit Agr wrote: From tree control, I am trying to send
SendMessage(TVM_DELETEITEM, WPARAM(0), LPARAM(hItem));
You are sending that message from the tree control where? How? To where? TVM_DELETEITEM is sent TO the tree control usually to delete an item, not by the tree control.
Amrit Agr wrote: I have handled this msg in view file like this
ON_MESSAGE(TVM_DELETEITEM, OnTvmDeleteItem )
but it simply delete the item and doesn't caught at OnTvmDeleteItem(). This implies that you want to handle the delete-item in your custom tree control, is that correct?
Amrit Agr wrote: I have also tried to send TVN_DELTEITEM with ON_NOTIFY_MESSAGE(), but still it doesn't work. You use ON_NOTIFY_MESSAGE to catch messages, not to send them, what you say here is confusing.
Please try to explain a bit more clearly what exactly you are trying to do.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
I want to handle deletion of tree item in other file, because I have to do some database work.
But this custom tree is used in so many applications, so that I can't send to directly to any window. I have handled that TVM_DELETE message in other file, and assume It should get called. but it can't reach at the specified function.
Should I try PreTransalteMessage() in other file after mapping WM_KEYDOWM do the particular deletion and database work?
|
|
|
|
|
You want to get a notification when an item (or more items?) are deleted from the tree?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
From what you are saying here you are mis-using this message. You should capture the TVN_DELETEITEM notification in your TreeView control and use the information passed to you to decide what action to take. You should then call your alternative function directly to perform whatever actions are necessary; there is no need to use (and you probably should not use) SendMessage() for that purpose. Something like:
ON_NOTIFY(TVN_DELETEITEM, id, DoTvnDelete)
...
LRESULT DoTvnDelete(...)
{
LRESULT lrc = DoDeleteAction(parameters ...);
return someResult;
}
The best things in life are not things.
|
|
|
|
|
Thanks Rechards,
I was going on the right direction.
Amrit Agrawal
|
|
|
|
|
I am using mmioxxxx library / API to build and save wave in RIFF file.
I can record the audio wave, save it in file and play it Windows Media Player.
However, I cannot load the file and verify the RIFF format in my code properly.
The “data” chunk is not aligned – I get two characters and then “da”.
Consequently I cannot use waveOutOpen and play the file myself.
All audio recording code presented here either does not save and load the RIFF file to play it or skips some header information.
I would like a sample code using either CFile or mmioxxxx file to compare with my code so I can find this “bug”.
I do not need anything else, I think I got the wave API covered.
Any constructive help will be as always appreciated.
PS I feel this is a long shot so I did not post my code. I do that if requested.
Cheers
Vaclav
|
|
|
|
|
I think I found it - the header structures if file saved and file loaded did not match.
|
|
|
|
|
I've had a similar sounding experience when writing out file-header structures in the past.
For me, the solution was as simple as checking that sizeof(my_header_struct) did indeed equal the correct size of the header struct. I found that it didn't and also found parts of it becoming misaligned.
After determining that the structure size was wrong, I found that the compiler was 'thoughtfully' padding the struct for me to a 4/8/16 byte multiple to make it quicker to access in memory. It was as simple as compiler directives to ensure that the struct was as specified and did not include this padding.
Using gcc, the relevant directives are:
#pragma pack(push, xxx)
#pragma pack(pop) Where xxx is the size of the alignment block you'd like - i.e if xxx = 2 then the struct will be padded to a multiple of 2 bytes. For my use, xxx very nearly always = 1. Just place the first directive before the struct is defined and the second after it, you may place several structs between the directives if needed.
I don't know if this is/was the problem - digging through old code, I can remember that this was needed for BMP headers, and if memory serves me correctly - I also needed this when reading the sound samples from the old games Doom & Rott.
Cheers
|
|
|
|
|
I have narrowed it down to missaligment of RIFF "data" descriptor.
I found one coder just doing a do / while loop to find the "data".
I am doing just that, it is a kluge but so far so good.
I am ready to get the real data out.
Thanks for the suggestions.
Vaclav
|
|
|
|
|
I appears that RIFF WAVE "format" chunk has an additional and so far unidentified variable.
It suppose to be used when the wave compression format is different than 1 = no compression.
That is why the actual data chunk identifier "data" was missalligned.
Vaclav
|
|
|
|
|
I'm just being lazy here but is there a way in the Visual C++ IDE (any version) to have it tell you what exceptions have been declared (by any of the methods or methods called by those methods etc...) to be possibly thrown?
The only way I know of is to dig through MSDN researching each method call which can get time consuming since there are so many overloaded method variations that I tend not to assume the possible exceptions that could be thrown by one overloaded method will be the same as another overloaded method.
|
|
|
|
|
WinError.h contains all of the error codes generally thrown by WinAPI/MFC calls, but generally speaking, there's no clear way of knowing what each method will throw without looking into the documentation associated with that specific method.
|
|
|
|
|
Albert Holguin wrote: WinError.h contains all of the error codes generally thrown by WinAPI/MFC calls
I'm just trying to quickly identify which catch handlers (if any) I would need at the level in the code where I'd want to handle them. Maybe some magic hover help that would allow you to see the summary of all the "throw" declarations for the method call, definition, or declaration your cursor is currently hovering over.
I apologize that I didn't word my question very good, now that I've reread it I guess it did sound like I just wanted a list of all the exceptions that could ever get thrown anywhere.
Regardless, thanks for taking the time to reply.
|
|
|
|
|
bob16972 wrote: Maybe some magic hover help that would allow you to see the summary of all the "throw" declarations for the method call, definition, or declaration your cursor is currently hovering over.
Sorry, no such magic...
|
|
|
|
|
A basic rule of exception handling is also that you only handle exceptions that you are aware and knowledgeable of. You shouldn't just catch any and all exceptions, except for maybe at the top level of your code.
So, you need to look into the documentation to see what exceptions are thrown and how to handle them anyway. It'd still be nice indeed to see what exceptions could be thrown so you can quickly check what you'd have to handle, but I'm guessing the documentation is quick enough for it anyhow, since you'll need to refer to it anyway to understand how to respond to the exception.
|
|
|
|
|
Hi Developers,
I want to send TVN_BEGINLABELEDIT message from a custom tree control, whenever i will press F2 key( to rename the label ).In custom control I have handled PreTranslateMessage, in which after mapping VK_F2, I have written
SendMessage(TVN_BEGINLABELEDIT, WPARAM(hSelectedItem), 0L);
But in other file ( in which I have handled TVN_BEGINLABELEDIT ), doesn't get called.
Is there any mistake in SendMessage() calling or some other issue.
Thanks in Advance.
Amrit Agrawal
|
|
|
|
|
Try showing a bit more of your code so we can see exactly what you are doing - and don't forget to put it within <pre> tags for formatting. Is this MFC or Win32?
The best things in life are not things.
|
|
|
|
|
TVN_BEGINLABELEDIT is a notification, which isn't the same as a message. The message in this case is WM_NOTIFY.
You'll probably want to use TVM_EDITLABEL[^].
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Thanks Jones,
Now It's working.
Amrit Agrawal
|
|
|
|
|
Hi all,
can anybody please tell me how can i use the proxy settings in vc++ MFC Application?
thanks in advance.
|
|
|
|
|
|
this article use proxy settings of IE only what about other browsers?
|
|
|
|
|
I have extended a CComboBox and implemented three messages (or events) like below
BEGIN_MESSAGE_MAP(CComboCtrl, CComboBox)
ON_WM_KEYDOWN()
ON_CONTROL_REFLECT(CBN_EDITUPDATE, &CComboCtrl::OnCbnEditupdate)
ON_CONTROL_REFLECT(CBN_SELCHANGE, &CComboCtrl::OnCbnSelchange)
END_MESSAGE_MAP()
Now when a selection changes it calls OnCbnSelchange message-handler. I am using this class inside a dialog class. I have tried to register a message handler in that dialog class for CBN_SELCHANGE event but I think it is not receiving CBN_SELCHANGE event or it is sending that event to custom control. How can I handle CBN_SELCHANGE event inside a dialog class.
This is the implementation inside derived class (or custom control class)
void CComboCtrl::OnCbnSelchange()
{
GetLBText(GetCurSel(),m_str_sel);
}
|
|
|
|