|
I ended up doing this (pardon the formatting - I cut/pasted the code from my source, and CP's "code" tags seem to be ignoring the tabs that are there):
void CConfigDlg::OnClickHostlist(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
NM_LISTVIEW* pNM = (NM_LISTVIEW*)pNMHDR;<br />
<br />
int nCount = m_ctrlHostList.GetItemCount();<br />
<br />
LVHITTESTINFO ht;<br />
ht.pt = pNM->ptAction;<br />
m_ctrlHostList.SubItemHitTest(&ht);<br />
if (ht.iItem < 0 || ht.iItem > nCount)<br />
{<br />
int nItem = GetSelectedItem();<br />
m_ctrlHostList.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED | LVIS_FOCUSED);<br />
}<br />
else<br />
{<br />
m_ctrlHostList.SetItemState(ht.iItem, LVIS_SELECTED, LVIS_SELECTED | LVIS_FOCUSED);<br />
}<br />
<br />
<br />
*pResult = 0;<br />
}<br />
<br />
<br />
void CConfigDlg::OnDblclkHostlist(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
NM_LISTVIEW* pNM = (NM_LISTVIEW*)pNMHDR;<br />
<br />
int nCount = m_ctrlHostList.GetItemCount();<br />
<br />
LVHITTESTINFO ht;<br />
ht.pt = pNM->ptAction;<br />
m_ctrlHostList.SubItemHitTest(&ht);<br />
if (ht.iItem < 0 || ht.iItem > nCount)<br />
{<br />
int nItem = GetSelectedItem();<br />
m_ctrlHostList.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED | LVIS_FOCUSED);<br />
}<br />
else<br />
{<br />
m_ctrlHostList.SetItemState(ht.iItem, LVIS_SELECTED, LVIS_SELECTED | LVIS_FOCUSED);<br />
}<br />
<br />
*pResult = 0;<br />
}
This causes the last item to be selected in the list if the user clicks in the empty area of the control. What a pain in the ass...
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
Hello,
Thanks for the info but can't we achieve this using a OnItemchangingMyList function ? :
void CSQLiteAddressBookDlg::OnItemchangingListContacts(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;<br />
<br />
<br />
*pResult = 0;<br />
}
As specified in the Celtic Wolf FAQ, I should affect FALSE or 0 to pResult in order to cancel the selection change. But it doesn't work.
I even tried to use OnNotify but can't find a way to make it work. It seems events LVN_ITEMCHANGED or LVN_ITEMCHANGING never occur.
<br />
BOOL CSQLiteAddressBookDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) <br />
{<br />
switch (wParam)<br />
{<br />
case IDC_LIST_CONTACTS:<br />
{<br />
LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;<br />
<br />
switch (pnmv->lParam)<br />
{<br />
case LVN_ITEMCHANGED:<br />
{<br />
TRACE0 ("LVN_ITEMCHANGING\n");<br />
<br />
break;<br />
}<br />
<br />
case LVN_ITEMCHANGING:<br />
{<br />
...<br />
break;<br />
}<br />
}<br />
<br />
break;<br />
}<br />
}<br />
<br />
return CDialog::OnNotify(wParam, lParam, pResult);<br />
}<br />
I checked codeproject tutorials and can't find anything about using OnNotify with List controls.
Thanks,
JM
Earth > Europe > France > Lyon
|
|
|
|
|
Bonjour,
Je me pose beaucoups de question sur les dialogues avec MFC, et je cherche quelque éclaircissement.
1) Imaginer le dialogue d'un effet de photoshop, on y trouve une image de preview et juste en dessus des boutons + et - pour le zoom. Eventuellement on peut cliquer sur l'image pour y ajouter le centre d'un effet ou déplacer l'image à la souris.
Est-il possible en MFC d'encapsuler l'image de preview, les boutons de zoom et le comportement de la souris sur l'image dans un nouveau control personnalisé (une classe) ? et comment ? Le but est d'éviter de recopier le même code 100 fois si j'ai 100 effets dans mon soft.
2) Pour l'image de preview, j'utilise un control de type bouton en owner draw car en plus de l'image j'ai des dessins à effectuer sur l'image. Est-il possible d'utiliser un control picture au lieu d'un bouton, et comment faire pour dessiner sur le control picture ?
L'avantage du control picture est que je peux y insérer une bitmap dans l'éditeur de dialog et faire ajuster à la taille du contenu pour avoir un dialogue de la bonne dimension au pixel près. Retailler le bouton dans l'éditeur ne permet pas de modifier sa taille au pixel près. Ou alors j'ai pas vu comment ??
3) Enfin, je voudrais avoir des control edit dans mes dialogues pour pouvoir modifier les positions de mes sliders par exemple. Je n'ai pas trouvé quel événement utiliser pour modifier la valeur du slider seulement quand j'appuie sur "return" dans le edit.
J'ai essayé onchange, mais ça change tout le temsp (si je veux entrer -42, il applique l'effet sur - pui -4 puis -42 et c'est le même problème quand j'éfface la valeur).
J'ai essayé onkillfocus, mais ça m'oblique à fait "tab" ou à cliquer sur un autre control pour valider la valeur. Dans ce cas, quand j'appuye sur "return" la valeur est bien modifier, mais manque de bol, le dialogue se ferme également comme si j'avais appuyer sur OK.
Des idées pour faire fonctionner tout ça ?
Merci d'avance,
|
|
|
|
|
bumper wrote (translated via Google):
Hello, I am posed beaucoups question about the dialogues with MFC, and I seek some explanation. 1) Imaginer the dialogue of an effect of photoshop, one finds there an image of preview and right in top of the buttons + and - for the zoom. Possibly one can click on the image to add the center of an effect or to move the image with the mouse to it. Is it possible in MFC to encapsulate the image of preview, the buttons of zoom and the behavior of the mouse on the image in a new personalized control (a class)? and how? The goal is to prevent recopying the same code 100 times if I have 100 effects in my software. 2) For the image of preview, I use a control of the button type in owner Draw bus in addition to the image I have drawings to carry out on the image. Is it possible to use a control picture instead of a button, and how to make to draw on the control picture? The advantage of the control picture is that I can there insert a bitmap in the editor of dialog and make adjust with the size of the contents to have a dialogue of the good dimension except for the pixel. To recut the button in the editor does not make it possible to modify its size except for the pixel. Or then I did not see how?? 3) Enfin, I would like to have control edict in my dialogues to be able to modify the positions of my sliders for example. I did not find which event to use to modify the value of the slider only when I support on "return" in the edict. I tested onchange, but that changes all the temsp (if I want to enter -42, it applies the effect on - pui -4 then -42 and it is the same problem when I éfface the value). I tested onkillfocus, but that obliques me with fact "" or to click on another control to validate the value. In this case, when I appuye on "return" the value is well to modify, but lack of bowl, the dialogue is also closed as if I had to support on OK. Ideas to make function all that?
It sounds like you need a control that provides image display capabilities with zoom and editing. I'm sure there are any number of ActiveX controls out there, either commercial or shareware, that would let you do this.
(translated via Google):
Cela ressemble à de vous le besoin une commande qui fournit à des possibilités d'affichage d'image le bourdonnement et l'édition. Je suis sûr qu'il y a tout nombre de commandes d'ActiveX dehors là, ou film publicitaire ou le shareware, qui vous laisserait font ceci.
Software Zen: delete this;
|
|
|
|
|
Ooups.. Sorry
I don't have see this is an english website.
My english translation:
Hello,
I'm developping with MFC, so I have problems with dialogs.
1) I have created an effect dialog like those of photoshop with a preview image, 2 buttons (zoom in, zoom out), a static control displaying the level of zoom, some mouse interaction, and display properties (owner draw)..
I would like to create one new control with contains all this features (in a class CPreviewBox for example).
Is it possible with MFC to create news controls like this I want to create ? Because I will have 100 effects, I don't want to copy/paste 100 times the same code. I want to include in the 100 dialogs an object CPreviewBox which deal with preview.
2) For now I use a button control to display my preview in (with owner draw) but the dialog editor not allow to resize the button pixel per pixel (ie. I want a preview 160*160, the best I had with editor is 161*159). So I would like to use a picture control which can be initialised to good the size (fit to content using a reference bitmap).
Is it possible to draw in the picture control and how ? because this ctrl don't have owner draw property. I want to draw line, circle.. on the preview image.
3) Finally, I want a edit control which can send his value to a slider control when the user press "return" (the dialog windows must stay opened).
I have try with OnChange but it's not possible because if I have to enter -42, with OnChange the effect will be recompute with - -> -4 -> -42.
I have try OnKillFocus, but when I press enter, the windows disapeared (because OK is pressed at the same time). Moreover with OnKillFocus, the user must press "tab" ou clic in another control to validate the edit control value.
What is the way to code this kind of event on an edit box (validate when user press return)
Thanks in advance,
Ignore the preview french thread.
|
|
|
|
|
bumper wrote:
Est-il possible en MFC d'encapsuler l'image de preview, les boutons de zoom et le comportement de la souris sur l'image dans un nouveau control personnalisé (une classe) ? et comment ? Le but est d'éviter de recopier le même code 100 fois si j'ai 100 effets dans mon soft.
Salut,
Oui, il est possible de faire ça, il faut simplement créer une classe avec les différents controls ( boutons, images, ... ).
Le plus simple est de générer cette classe à partir d'un dialogue, le dialogue peut alors être réutiliser partout dans l'application ( inséré dans un autre dialogue, inséré dans une ToolBar ( ControlBar ) ).
La classe que tu crée doit quand même être modifié pour gérer toutes les manipulations que tu veux y mettre. Il faut aussi que la classe puisse aussi utiliser les effets que tu veux y attaché; pour ça, il y a plusieurs possibilité, la plus simple ( selon moi ) est de passé à son constructeur un objet effect ( d'ou hérite tes différents objets.
Pour l'image elle même, je n'utiliserai pas un boutton owner draw, j'utiliserai un CWnd três ordinaire, mais autrement plus facile à "customisé".
Pur le 3, t'as pas le chois d'attendre soit le "enter" ou le "Tab", sinon, c'est à chaque touche du clavier. pour empecher que le dialogue ne se ferme quand tu tappes "enter", il faut que tu change une des propriété des edit box pour mettre à FALSE, la propriété WANT_RETURN, ou bien, change le ID du boutton OK, pour qu'il ne soit pas IDOK ( ou quelque chose du genre ), cherche ES_WANTRETURN dans l'aide en ligne.
Max.
|
|
|
|
|
Salut Max,
et merci pour ttes ces idées!!
>Le plus simple est de générer cette classe à partir d'un
>dialogue, le dialogue peut alors être réutiliser partout dans
>l'application ( inséré dans un autre dialogue, inséré dans une
>ToolBar ( ControlBar ) ).
Tu veux dire que je crée un dialog classique dans l'éditeur de ressource avec tts les boutons que je veux. Et que je peut directement réutiliser ce dialog dans un autre ??
J'ai crée le dialog en question.. mais comment je fais pour l'intégrer dans un autre ? peut-on le faire par l'éditeur ? ou doit-on se palucher le code tt seul ? (c'est peut être le "custom control" dans la liste des controls.. je vais voir)
>La classe que tu crée doit quand même être modifié pour gérer
>toutes les manipulations que tu veux y mettre. Il faut aussi
>que la classe puisse aussi utiliser les effets que tu veux y
>attaché; pour ça, il y a plusieurs possibilité, la plus
>simple ( selon moi ) est de passé à son constructeur un objet
>effect ( d'ou hérite tes différents objets.
Oui en gros je vais lui passer une image (ou un effet), et elle s'occupera des zoom, du déplacement de l'image à la souris, capturera les cliques souris..
Au passage. Ya-t-il une fonction windows pour tester les boutons de la souris depuis n'importe où dans l'application (du genre GetCursorPos() mais pour les boutons gauche et droit ?).
Pour le CWnd, je vais essayé, mais je m'en suis sorti avec le bouton.
Pour le reste, je vais voir pour désactivé la fermeture de fenetre avec ce que tu m'as dit.
|
|
|
|
|
Hi
I have to paste bitmap into the clipboard (CF_BITMAP). Some other application will retrieve this bitmap lately. After this retrievement I want to delete my bitmap from the clibpoard and restore previous content of the clipboard. The problem is that before I paste something I have to clear the clipboard (EmptyClipboard). So I suppose that to restore the clipboard I will have to do as follows:
1) copy whole clipboard content in my app
2) clear clipboard
3) paste my bitmap
4) retrieve bitmap in other app
5) clear clipboard
6) restore clipboard using data created in pt.1
Copying all standard clipboard formats will be very laborious. I don't know whether it will be possible to copy registered clibpoard formats.
So the question is: Is there an easy way to do what I want (pasting bitmap into clipboard and after some time removing this bitmap from clipboard, so the clipboard has the same content as it has before my manipulations)? Thanks in advance for any help.
Mariusz Popiolek
|
|
|
|
|
First, I don't think you need to save and restore the entire clipboard content. You should be able to save and restore only the data in the format you are using (CF_BITMAP , in this case).
Secondly, this entire idea isn't standard Windows behavior. The clipboard is manipulated using cut, copy, and paste under user direction. Clearing the clipboard and restoring previous contents doesn't sound like a good idea.
Software Zen: delete this;
|
|
|
|
|
>First, I don't think you need to save and restore the entire clipboard >content. You should be able to save and restore only the data in the format >you are using (CF_BITMAP, in this case).
I empty clipboard before I paste something (if I don't empty clipboard my bitmap doesn't appear if there was something in clipboard before pasting), so I need to save the entire clipboard (or maybe I'm doing something wrong and emptying clipboard is needless).
>Secondly, this entire idea isn't standard Windows behavior. The clipboard >is manipulated using cut, copy, and paste under user direction. Clearing >the clipboard and restoring previous contents doesn't sound like a good >idea.
I suppose you are right, but unfortunately I have to do this.
Mariusz Popiolek
|
|
|
|
|
Is your bitmap supposed to be pasted into a separate program? Or will you just be moving it back and forth between your program?
Because how do you queue off the command to restore the clipboard to its original state? After you paste the bitmap? Because if you paste it into another program then I do not think that you will have any way of telling that someone else pasted your data.
Also, what happens if someone wants to paste more than one copy of your bitmap. Will this ever be a possibility? Because then they would have to go back to the original window and make another copy of it.
If the bitmap communication is only between apps that you have complete control over, I would suggest a memory mapped file or some other form of IPC to share the data between your app(s).
To answer your question, look into making your window a clipboard viewer. If it is in the viewing chain, it may be easier for you to extract and save all of the data. I beleive that you get some of these notifications when a clipboard format is used as well.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I think that I have explain what I'm doing at the moment. I have done Ms Office plugin and AFAIK the only way to make toolbar in Ms app with my own icons is to paste some bitmap into the clipboard and after this create new toolbar and copy bitmap from clipboard. The problem is that I want to preserve previous content of the clipboard. I'm pasting my bitmap by calling some function from my dll (this calling is inside Office macro), after that I create new toolbar, and then I want to restore clipboard content (of course by calling another dll function)
Mariusz Popiolek
|
|
|
|
|
What are the constants defined in cmath?
|
|
|
|
|
What're the constants defined in the <cmath>?
|
|
|
|
|
Hi! How to detect whether the network connection is available for a machine
running Win2K? What is the API i can use?
Thanks a lot!
|
|
|
|
|
This depends on what you are using the network connection for.
If you want to use WinSock to talk to a remote machine, you can use a ping function. For example, this article[^] provides a C++ class for doing pings.
If you need to see if a given network share is available, just try to do a CreateFile or OpenFile on it. You could also use the functions in the Windows shell[^] to enumerate the contents of the 'Network Neighborhood' to find out what shares are available to your machine.
In other words, the simple approach is to assume that the network connection is there, and attempt the operation you are interested in. If the operation fails when it otherwise should succeed, in all likelihood the network connection isn't available.
Software Zen: delete this;
|
|
|
|
|
InternetGetConnectedState() will do it for you.
--Mike--
"alyson hannigan is so cute it's crazy" -- Googlism
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
1)
I added WS_MAXIMIZE in PreCreateWindow to my main MFC Frame window.
Works fine, maximizes at start like it should.
However, it is not maximized when OnCreate is called(At least GetWindowRect() doesn't see it like that), but I need to position some other windows relative to it in the maximized state.
How can I accomplish this?
2) How can I make child windows start out maximized? I tried WS_MAXIMIZE and MDIMaximize() of the frame window, but nothing happens with either...
|
|
|
|
|
Locked Ghost wrote:
(At least GetWindowRect() doesn't see it like that)
Use SystemParametersInfo(SPI_GETWORKAREA,...) to find out the size of a maximized top-level window.
Locked Ghost wrote:
How can I make child windows start out maximized?
I've not done a lot of MDI programming, but I would assume you'll have to wait until the frame window has been created and put on the screen before you can maximize any MDI child windows. If you are using the MFC document/view stuff, you could have your view tell the frame to maximize the child in OnCreateClient() .
Software Zen: delete this;
|
|
|
|
|
Gary R. Wheeler wrote:
Use SystemParametersInfo(SPI_GETWORKAREA,...) to find out the size of a maximized top-level window.
Hmm... it seems to be off by a few pixels. What could be causing this? Anything special I need to know about it?
Gary R. Wheeler wrote:
I've not done a lot of MDI programming, but I would assume you'll have to wait until the frame window has been created and put on the screen before you can maximize any MDI child windows. If you are using the MFC document/view stuff, you could have your view tell the frame to maximize the child in OnCreateClient().
MDIMaximize doesn't seem to do anything no matter where I call it from
|
|
|
|
|
The workarea is the rectangle that a window is the desktop window - any appbars that may be present.
So if you have your Windows Taskbar viewable without autohide, that would account for your few pixels of discrepency. Otherwise, if that is not the case could you give some more details.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Yes, I have the taskbar on without autohide...
but I still don't really understand where those few missing pixels come from... could you explain it?
|
|
|
|
|
What is your current screen resolution, and what are the values that are returned from the call to SystemParametersInfo?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I've refied the problem a bit.
It returns 0, 0 and the other one is right too.
However, GetWindowRect() on a maximized window returns negative values(-4, -4 i belive) for the first corner
Why?
|
|
|
|
|
How can I get the active view(or document)?
I need a window to access the active document, but I didn't find any clues about doing it anywhere...
|
|
|
|
|