|
Hi together,
I put a ListView in my Dialog and wand to catch the LVN_BEGINDRAG Notify-Message.
The ListView has his Notify-property to TRUE.
I tried a ON_NOTIFY_RECENT(LVN_BEGINDRAG,OnDrag) but i never step into it.
A tutorial says that the LVN_BEGINDRAG Notify message is catchable with adding a
new handler via the class wizard.
I tried a lot of things, but i don't find it
Does anyone knows where to add it?
Big thanks
|
|
|
|
|
Resource view -> mark the listctrl
Right click -> Context menu "Add event handler..."
proceed...
It is not so easy to find I still miss the VC6 (CTRL+W) wizard
Greetings from Germany
|
|
|
|
|
Danke für deine Antwort
I only have SetFocus, KillFocus, ThemeChanged, ...
No one likely "BeginDrag" or Notify
|
|
|
|
|
First you must open the Resource view (open the *r.rc file) of your dialog then click at the Treeview. Now right click ...
Greetings from Germany
|
|
|
|
|
Muss ich die Liste zuerst noch als Klasse ableiten?
Denn ich bin im Ressourcen-Modus, sehe den Dialog mit ner Textbox & dem Listen-Control.
Dann wähle ich die Liste aus und gehe auf "Ereignishandler wird hinzugefügt"
Dort drin habe ich jedoch nur Doppelklick, Focus Ereignisse
Nicht was mit Drag&Drog zu tun hat.
Irgendwo ist da der Wurm drin LOL
|
|
|
|
|
I cannot seem to find a message that will give my code a call after the user marks the checkbox on a standard CTreeCtrl. I can trap on the NM_CLICK but that calls me before the checkbox is marked, however, I want to be called after the state of the node is set. Thanks
|
|
|
|
|
I thought this was going to be a trivial question, but I can't see a nice elegant method either.
What you can do is....
1/ Get NM_CLICK
2/ Get the cursor position with GetMessagePos, and translate it to tree window coords.
3/ Use TVM_HITTEST to get the item number, and where the click was (does it return TVHT_ONITEMBUTTON ?)
4/ Get the current check state.
5/ Either get on and handle the fact that the state will change, or post yourself a message to deal with it shortly.
Iain.
|
|
|
|
|
OK, you officially owe me a pint.
There isn't a clear message, but as its a common control, you get owner draw notifications when things have changed. Including the check box...
The below code will raise some repeated messages, eg when you scroll. So in your handling code, I'd check if the change is really a change, or just a redraw.
Iain.
ON_NOTIFY(NM_CUSTOMDRAW, IDC_TREE1, OnTreeCustomDraw)
void CMyDlg::OnTreeCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
NMTVCUSTOMDRAW *nmtv = (NMTVCUSTOMDRAW *)pNMHDR;
switch (nmtv->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW;
return;
case CDDS_POSTPAINT:
break;
case CDDS_ITEMPREPAINT:
TRACE1("uItemState=%x\n", nmtv->nmcd.uItemState);
{
BOOL bState = TreeView_GetCheckState (::GetDlgItem (GetSafeHwnd (), IDC_TREE1), (HTREEITEM) nmtv->nmcd.dwItemSpec);
TRACE1(" Check state = %i\n", bState);
}
break;
case CDDS_ITEMPOSTPAINT:
case CDDS_ITEMPREERASE:
case CDDS_ITEMPOSTERASE:
break;
default:
TRACE1("Unexpected draw state =%i", nmtv->nmcd.dwDrawStage);
break;
}
}
BOOL TreeView_GetCheckState(HWND hwndTreeView, HTREEITEM hItem)
{
TVITEM tvItem;
tvItem.mask = TVIF_HANDLE | TVIF_STATE;
tvItem.hItem = hItem;
tvItem.stateMask = TVIS_STATEIMAGEMASK;
TreeView_GetItem(hwndTreeView, &tvItem);
return ((BOOL)(tvItem.state >> 12) -1);
}
|
|
|
|
|
Works great, definately worth a pint... Thanks Iain.
|
|
|
|
|
Hi all,
I have a problem regarding performance of my application in which I have many images in tabpane in which user can select any tab and the appropriate result will be shown to the user respective to the selected tab in my MFC application.
But when user made click on that there is much fluctuation to display data and it takes long time to display a single text line.
I have loaded images by the following code:
m_btnHelp.SetButtonStyle(BS_OWNERDRAW);
m_btnHelp.LoadBitmaps(IDB_BTN_MAINHELPD,IDB_BTN_MAINHELPH,IDB_BTN_MAINHELPD);
So, can any one help me to solve this slow performance problem
or anybody knows how to load this images and open respective pages fast.
Thanks in advance!!!
|
|
|
|
|
I think you are redrawing to much. Or what else are you doing in your drawing code?
Greetings from Germany
|
|
|
|
|
Hi
I can't get your point what is redrawing means???
|
|
|
|
|
You wrote: "much fluctuation to display data and it takes long time to display a single text line"
it sounds like you draw or Invalidate() to much. Make a breakpoint in your drawing code or TRACE-statement.
Greetings from Germany
|
|
|
|
|
Hi,
Thanks for giving me your valuable time....
I have made a simple application in which if user clicks on one button then the respective page will open.
In that page I have put some buttons and at last I have attached some images to that buttons.
So, while I am clicking on the main button then the next page in which I have attached images will open after 2-3 seconds means fluctuation is displayed images are not loading fast.
So, can you please tell me where I am wrong from which I am suffering from this problem.
Thanks again
|
|
|
|
|
You need to load the images before you display the dialog. The OnInitDialog() Function is a real good place.
I would strongly advise you to learn a lot via downloading samples from CP.
Greetings from Germany
|
|
|
|
|
Hi,
LoadBitmaps belongs to CBitmapButtons right, where it resides in page or you are using it instead of Tab control
for CBitmapButtons i think BS_OWNERDRAW has to be set in Create.
|
|
|
|
|
hi sir,,
iam displaying files on the list view ... like file1,file2 ...etc.
after that iam providing multiple selection files on list view.
that is ok.. no problem. then what problem is i would like unselect the files
which files are selected.
plz give me reply
Regards,
Srinivas
|
|
|
|
|
Try this...
POSITION pstPos = GetFirstSelectedItemPosition();
while( pstPos )
{
const int nItem = GetNextSelectedItem( pstPos );
SetItemState( nItem, 0, LVIS_SELECTED );
}
|
|
|
|
|
Hi,
How can I get the System Harddisk Serial Number in MFC. I need HD Serial number for Security isssues related to my project.
Thanking You
with regards
swamy
|
|
|
|
|
Either can use WMI or have a look at this[^] article by dmihailescu.
Though there is some .net related stuff, it uses native API's to extract required information.
Prasad
MS MVP - VC++
|
|
|
|
|
|
Hi,
Can anybody pls tell me how to handle Exceptions in Constructor,in MFC?
Thanks
Today is a gift, that's why it is called the present.
|
|
|
|
|
what's the problem exactly ?
can't you just handle it as you do anywhere else ?
moreover, if you have an exception in a constructor, it's probably that an error occured and your object might not be constructed correctly... so think twice before catching there.
|
|
|
|
|
Hi all,
I keep getting this exception:
First chance exception at $7C812A5B. Exception class EOSError with message
'System Error. Code: 1400.Invalid window handle'. Process Application.exe (2932)
I have no idea where the exception takes place cause my compile open some funny code that I'm not familier with. does anyone know how to handle such an exception, or maybe what I'm doing wrong.
Many Thanks
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
Maybe posting relevant code (your not the one VS IDE prompted) will help.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|