|
I think he might be worried about black hats
installing SMTP servers on non-standard ports
on machines somewhere in his network and using
his domain for sending spam, porn, warez or
what-have-you? In that case, you can try
connecting to ports (all of them) and talking
SMTP, looking for a server. Or you can watch
traffic on the network and try to sniff out
culprits.
(of course, would they make it stand out as
what it is by speaking plain ol' SMTP? I dunno.)
I wonder what the goal was?
|
|
|
|
|
I have a dialog based application that includes a modal dialog that has a CComboBox in it. I have attached a control variable (through the class wizard in MFC) to the CComboBox because I need the strings in the box to change dynamically depending on other settings in the program. The combo box works fine the first time the dialog is opened, but if I re-open the dialog the control variable causes a crash (assertion error) because it is no longer pointing to the combo.
Can anyone help me with this problem? I need that control variable to point to the combo every time the dialog opens.
|
|
|
|
|
Hi,
I am populating a treeview with some data and since there are too many and too long items my app requires even more and more memory.
To avoid this I decided to use single select mode and add only those items to the tree which belong to the CURRENTLY expanded node.
If this node gets collapsed all items are removed from this node. In that way the app's footprint might be significantly reduced.
Problem: the whole tree must be kept in and read in from a file according to a certain algorithm.
I need your advice as to how you would do this.
Thanks in advance.
Bunburry
|
|
|
|
|
// CollapseBranch - Collapses a branch completely
// hti - Handle of the tree item to collapse
void CTreeCtrlX::CollapseBranch( HTREEITEM hti)
{
if( ItemHasChildren( hti ) ){
Expand( hti, TVE_COLLAPSE );
hti = GetChildItem( hti );
do{
CollapseBranch( hti );
}while( (hti = GetNextSiblingItem( hti )) != NULL );
}
}
Expanding a branch
--------------------------------------------------------------------------------
The treeview has built in support for expanding expanding the outline one level at a time. If you want to completely expand a branch, the code below will help. It uses recursion to expand all items. The last line, that is, the call to EnsureVisible() is useful when this code is hooked up to a user interface. After expanding the outline branch, the previously selected item may have scrolled off and calling EnsureVisible() brings it back.
// ExpandBranch - Expands a branch completely
// hti - Handle of the tree item to expand
void CTreeCtrlX::ExpandBranch( HTREEITEM hti )
{
if( ItemHasChildren( hti ) ){
Expand( hti, TVE_EXPAND );
hti = GetChildItem( hti );
do{
ExpandBranch( hti );
}while( (hti = GetNextSiblingItem( hti )) != NULL );
}
EnsureVisible( GetSelectedItem() );
}
search more in codeguru and codeproject
|
|
|
|
|
I must have asked in the wrong way:
The real question is how can I serialize a treeview into a file so that I can retrieve its nodes any time.
When I expand an item, I have to read in its childs from the file, when I collapse delete all items in this node because all subitems are saved in the file in question.
Anyway thanks for the feedback.
Bunburry
|
|
|
|
|
I need to be able to create some controls as the user needs them. They are all the same control. I will need to be able to still get access to each controls messages etc. At the time the appliction starts to run I will not know how many controls the users will be using, but there will be a max number of controls that the user can create.
How can I do this in VC++? If anyone can point me in the right direction I will be happy to do the research. I looked over at MSDN but could only find examples for VB.
Thanks,
-Eric
|
|
|
|
|
Option 1: You could create all controls with the dialog editor in the non visible state, and show/hide them according to user input with ShowWindow(SW_SHOW/ShowWindow(SW_HIDE)
Option 2: Create them dinamically with the controls Create method.
Bunburry
|
|
|
|
|
Bunburry wrote:
Option 2: Create them dinamically with the controls Create method.
Bunburry,
This is the option that I was hoping for. The question is how can I do this? Do I just declare a and array like I normally would of the control type that I want?
int MAX_CONTROLS = 50;
CEdit EditArray[MAX_CONTROLS];
for(int i = 0; i < 50; i++)
{
EditArray[i].Create();
}
Is this similar to how it work? How do I know which array element has been clicked on or text entered etc?
Thanks,
-Eric
|
|
|
|
|
VanHlebar wrote:
Is this similar to how it work?
Yes, that may not be the exact syntax, but that is how you would set up your array of Edit controls.
VanHlebar wrote:
How do I know which array element has been clicked on or text entered etc?
There is no mechanism in C++ that allows you to handle the controls based on an index. However you can set this up yourself. First off, you can set the same handler for each of the controls. If you need to know the index of hte control in your array, you can do one of two things:
1) Search for the current object in your array, and when you find the object you will know the index.
2) Is a little bit more complicated, but you can use SetWindowLong with the GWL_USERDATA flag, and set the index there. That way whenever your window needs to know which index it possesses you can simpy query GetWindowLong.
3) And I just thought of a third, you can create a derived class from CEdit that has a place where you can store the index ID that you want to give your control.
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!
|
|
|
|
|
When you process the control's notification message do something like this:
For example, it is and edit control and then message sent to the parent window is EN_CHANGE:
case EN_CHANGE:
iControl = GetWindowLong((HWND) lParam, GWL_ID);
switch(LOWORD (wParam))
{
/* code of what you want to do using the arrayname and for an index
* use iControl
*/
}
...
|
|
|
|
|
m_btnFirst.Create("Button1", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, rect1, pWnd, IDC_BUTTON_FIRST);
m_btnSecond.Create("Button2", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, rect2, pWnd, IDC_BUTTON_FIRST + 1);
m_btnThird.Create("Button3", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, rect3, pWnd, IDC_BUTTON_FIRST + 2);
...
Message map:
BEGIN_MESSAGE_MAP(CYourDlg, CDialog)
ON_CONTROL_RANGE(BN_CLICKED, IDC_BUTTON_FIRST, IDC_BUTTON_FIRST + nNumberOfButtons,OnRange)
END_MESSAGE_MAP()
OnRange(UINT nID) is the dialogs function that gets called when any of the buttons is pressed. the Button's ID will be in the nID variable.
Important: make sure your IDC_BUTTON_FIRST is defined in resource.h with a unique value, and that there are no other controls in the IDC_BUTTON_FIRST + nNumberOFButtons range.
Bunburry
|
|
|
|
|
Hi I have word automated application...
It takes input document (.doc) file name from the command line, then open it, format it, print it, and close the MS Word application with MSWord9...
Another dialog-based application calling wordAutomation application passing with filename as an argument. Once wordAutomation gets the document file name, it open, format, and print the file.
Here the problem comes, wordAutomation takes so long to close the MSWord application... it takes 3 mins to close up MSWord application..
There isn't such kind of problem using wordAutomation itself ( not calling from another application). It does all its jobs (open,format,print, and close) very fast ... but why it takes so long to close the MSWord program if it got called from another application?
here the code how I close MS Word in wordAutomation program.
<br />
document.PrintOut(COleVariant((short)false), vOpt, vOpt, vOpt, vOpt, vOpt ,vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, COleVariant((short)12240), COleVariant((short)15840));<br />
<br />
document.Close(COleVariant((short)false), vOpt, vOpt);<br />
documents.ReleaseDispatch();<br />
<font color = red> here I think is a problem at closing the MSWord when wordAutomation program is called from another application. I used "I think " coz I don't know how to debug at run time. </font><br />
app.Quit(covFalse,covFalse,covFalse);// quiting the MSWord application.<br />
app.ReleaseDispatch();<br />
<br />
|
|
|
|
|
I have some threads in my app. I want one to run to use max cpu which it does quite nicely already, I want another to use 10%-20% cpu, how can I say "Thread #2, you can only use 20%, not 50%" without the thread getting angry?
I have already tried tweaking the thread priority in real time, but this doesn't work very well, any other ideas would be great...
|
|
|
|
|
|
VC6, SP5
I have a CListCtrl in a CDialog. In ClassWizard, I turned on "Show Selection Always", and in OnInitDialog, I've turned on the LVS_EX_FULLROWSELECT | LVS_EX_ONECLICKACTIVATE extended styles for the list control.
After clicking on an item, it highlights (as expected). When I click on an area of the listcontrol that does not have an item, the highlight goes away for the last selected item, but the program still thinks it's selected.
If I click a number of times in the empty area, the highlight comes and goes. If I click on the item again, the highlight comes back.
I want to do one of two things:
1) Do not allow the highlight to be removed from the selected item when I click on the empty control area (this is the preferred method).
2) Un-select the item when I click on the empty control area.
I'm trying to avoid subclassing the CListCtrl because there's a lot more issues involved with doing so.
Opinion - MFC's CListCtrl class SUCKS.
------- 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
|
|
|
|
|
These aren't problems with CListCtrl per se, but the Windows list-view control underneath, which is an A-number-1 mother-batch when it comes to handling selections. The essence of modifying the selection behavior is to handle the LVN_ITEMCHANGING and LVN_ITEMCHANGED notifications.
LVN_ITEMCHANGING lets you decide whether or not to permit a state change in a list view item. In this case, you could find out where the user clicked and use that to make the decision. LVN_ITEMCHANGED tells you after an item's state changed.
Software Zen: delete this;
|
|
|
|
|
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;
|
|
|
|
|