|
I think you should try a GetParent function wich is suppose to return the CWind* of the parent window. You can also have the hwind with (GetParent())->m_hWind
|
|
|
|
|
If There's a define or that, which I don't have in any of the include
files of VC, and that the help file doesn't say that I must have any
particular version of shell32.dll; should the default UI for
SHBrowseForFolder have a "new folder dialog" ?!?!!?
I'm a bit confused about the help for that shell function ...
Max.
|
|
|
|
|
You'll need to download the Platform SDK to get the latest header files. See the VC Forum FAQ (link at the top of the page) for more details.
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|
|
Go to your MSDN CDs, or msdn.microsoft.com (typing URL from memory) and get the latest SDK for the windows shell. It'll replace your shlobj.h file and provide the new values that you need to have defined.
You might also have to add WINVER=0x0400 in your settings - if you are using a feature that says Version 0.4 - you want 0x0400 for 5 you want WINVER=0x0500
I was puzzled by this too at first. FYI you can just plug in the values instead of relying on the defines and you'll be okay.
Hope this helps:
#define BIF_RETURNONLYFSDIRS 0x0001 // For finding a folder to start document searching
#define BIF_DONTGOBELOWDOMAIN 0x0002 // For starting the Find Computer
#define BIF_STATUSTEXT 0x0004 // Top of the dialog has 2 lines of text for BROWSEINFO.lpszTitle and one line if
// this flag is set. Passing the message BFFM_SETSTATUSTEXTA to the hwnd can set the
// rest of the text. This is not used with BIF_USENEWUI and BROWSEINFO.lpszTitle gets
// all three lines of text.
#define BIF_RETURNFSANCESTORS 0x0008
#define BIF_EDITBOX 0x0010 // Add an editbox to the dialog
#define BIF_VALIDATE 0x0020 // insist on valid result (or CANCEL)
#define BIF_NEWDIALOGSTYLE 0x0040 // Use the new dialog layout with the ability to resize
// Caller needs to call OleInitialize() before using this API
#define BIF_USENEWUI (BIF_NEWDIALOGSTYLE | BIF_EDITBOX)
#define BIF_BROWSEINCLUDEURLS 0x0080 // Allow URLs to be displayed or entered. (Requires BIF_USENEWUI)
#define BIF_UAHINT 0x0100 // Add a UA hint to the dialog, in place of the edit box. May not be combined with BIF_EDITBOX
#define BIF_NONEWFOLDERBUTTON 0x0200 // Do not add the "New Folder" button to the dialog. Only applicable with BIF_NEWDIALOGSTYLE.
#define BIF_NOTRANSLATETARGETS 0x0400 // don't traverse target as shortcut
#define BIF_BROWSEFORCOMPUTER 0x1000 // Browsing for Computers.
#define BIF_BROWSEFORPRINTER 0x2000 // Browsing for Printers
#define BIF_BROWSEINCLUDEFILES 0x4000 // Browsing for Everything
#define BIF_SHAREABLE 0x8000 // sharable resources displayed (remote shares, requires BIF_USENEWUI)
--Mark Terrano
|
|
|
|
|
I want to scan a file in binary mode looking for a string. What's the best way to accomplish this with STL? I'm looking for something that will handle buffered input instead of reading a byte at a time.
Todd Smith
|
|
|
|
|
In the continuing saga of me trying to solve a release build problem with CButtonSSL.
I have recently noticed during debuggin that parental class information is not available beyond the immediate parent in the variables window. So I can see the member data for the control itself and I can navigate through the tree to the parent COddButton, but beyond that (CButton and then CWnd) are not available and the Watch window won't allow me to cast up the inheritance tree beyond COddButton.
Any thoughts or suggestions? How on earth is this happening?
One other thing I've noticed is that when the offending code is called in CWnd that tries to dereference an invalid m_pCtrlSite (should be NULl but isn't) the window handle and value for this in the debug window aren't particularly valid either, i.e. values like 0x00000403 for this .
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
From your last paragraph I gather that you have some memory corruption going on somewhere in your code. You may try setting a conditional breakpoint to stop when the address of m_pCtrlSite changes (from NULL to 0x00000403). This should help you pinpoint where the memory is being overwritten.
There are a couple of articles here in CodeProject that may help you debug your code better in Release mode.
Good luck!
Alvaro
|
|
|
|
|
Alvaro,
Thanks for replying, it has been difficult trying to get some help with this problem.
Alvaro Mendez wrote:
From your last paragraph I gather that you have some memory corruption going on somewhere in your code.
I'm almost certain that this is happening, but I can't track down how or why. For example, in the DrawItem override for CButtonSSL there is a call to GetWindowText, which is obviously a CWnd function. When I step through the code everything appears to be fine in CButtonSSL (except that I can't expand the variable tree in the variables window above the COddButton parent), but then when I step into GetWindowText, the value for this , which is now the CWnd, is something like 0x00000403 and it is at this point that m_pCtrlSite is not NULL.
Alvaro Mendez wrote:
You may try setting a conditional breakpoint to stop when the address of m_pCtrlSite changes
It has not been possible to set an advanced breakpoint of this nature (and believe me I've tried for many hours ) because it doesn't like trying to cast the expression beyond a COddButton.
I have looked at the articles you mentioned. CP was the first place I looked.
Any more ideas?
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
OK, let's explore the conditional breakpoint route which is probably your best bet.
You can set a conditional breakpoint using the address of m_pCtrlSite.
1. When you're stepping through the code and you have m_pCtrlSite in scope, copy it to the watch window and add an ampersand in front of it: "&m_pCtrlSite".
2. This will give you its address. Now copy that to the clipboard.
3. Open the Breakpoints window and click on the Data tab.
4. Paste the address in there and press OK.
5. If m_pCtrlSite is already corrupt at this point, restart the program, otherwise continue it.
Hopefully you'll hit this breakpoint at the point of corruption and you'll get some clues. If not, try posting some code here to get a second (or more) pair of eyes looking at it.
Regards,
Alvaro
|
|
|
|
|
Alvaro,
Thank you very much for your help with this problem.
Having followed your suggested steps and through my own further examination it would seem that the problem lies in some corruption further up the chain. At the point where the crash occurs the address of m_pCtrlSite has changed, hence the invalid value.
I have managed to come up with some steps that will always reproduce the problem:
1. Create a dialog-based application using ClassWizard (accept the default values).
2. Add the files OddButton.h/.cpp and ButtonSSL.h/.cpp to the project (these files can be found in the source code from the article).
3. Add a check box to the dialog and add a control member variable for it.
4. Change the type of the member variable to CButtonSSL and add #include "ButtonSSL.h" to the dialog class.
5. In the OnInitDialog override in the dialog class, add a call to SetCheck (1) for the CButtonSSL member variable.
6. Build a release build and execute.
Upon execution an unhandled exception will occur following the call to GetWindowText in DrawItem .
If a breakpoint is set at the call to SetCheck (1) then you can see that the data for the member variable is fine and that m_pCtrlSite is NULL as it should be.
However, following the call to SetCheck I believe the dialog is told to redraw itself and it then tells the button to redraw itself. In the CWnd::DrawItem function there is a call to ReflectLastMsg . Using the evaluation of Mutek's BugTrapper tool it indicates that the value passed in as the first parameter to ReflectLastMsg (HWND hWndChild ) is a bad pointer.
I don't know how it knows this or why it is a bad pointer, but I suspect that the problem lies here. If it's reflecting the message to the wrong thing then it's bound to crash!
If you can explain to me why this is happening and more importantly how to fix it I will be eternally grateful (and you will of course get a mention when the article update is posted
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
Alvaro,
With some help from Joseph Newcomer I have at last come to the end of this problem.
The event handler for BM_SETCHECK, OnCetCheck did not include both parameters (WPARAM and LPARAM). I'm not quite sure why, but the exclusion of this unused parameter was causing all the problems.
Thanks for all your help.
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
Hello,
I want to make a dialog based application that requires the user to enter a username and password to enter.
So in the constructor of the Dialog box class of my application I create a child dialog login box. What I want to do is that if the user presses Cancel on the child login box, then the Application ends.
So to do this do I need to call the OnCancel method of the parent dialog box?
if yes then how do I call it?
Is there a better way to do this?
Thanks,
Mike.
|
|
|
|
|
You need to get the value that returns the Dialog.
In DoModal returns the Identificator of the button that the user presed.
For Ok returns IDOK for Cancel returns IDCANCEL.
You must to put this function in the OnInitDialog()....
Is easy....
Best Regards!!!!
Carlos Antollini.
|
|
|
|
|
You should do that in OnInitDialog() instead, because at that time the first dialog is created but not yet shown.
BOOL CMainDialog::OnInitDialog()
{
CPasswordDialog pwdDlg;
if ( IDCANCEL == pwdDlg.DoModal() )
EndDialog(IDCANCEL);
...
}
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|
|
Shall I create the child dialog box in the constructor of the Main Dialog box or in the OnInitDialog?
When I created it in the OnInitDialog then after I closed the Main Dialog Box I could still see the image of the child dialog box (not the box though).
This does not happen when I create the child dialog box in the constructor of the Main Dialog Box.
Any explanations?
|
|
|
|
|
Hello.
Printing again. The problem is how to position printer in order to get somehow precise output. For example: How to draw a frame which is equally distant from the edges of a page?, or how to draw division lines: vertical and horizontal in such a way that they divide an a4 page into two parts (more or less equal parts)?
At this time beeing I obtained less precise results (still,something is wrong) while using GetDeviceCaps & PHYSICALWIDTH(HEIGHT), PHYSICALOFFSETX(Y), but it produces different outputs (more or less accurate), depending on a printer (hp 1220 and 690).
PS. I have also used the pInfo->m_rectDraw rect but, it didn't print out the boundaries (the rectangle was to large to fit the printable area).
PLEASE, anyone able to help ?
|
|
|
|
|
It will be different depending on the selected printer and the resolution selected on it. You size to the printers parameters. Using GetDeviceCaps gives you all you need to calculate your graphic size or text formating.
HORZSIZE Width, in millimeters, of the physical screen.
VERTSIZE Height, in millimeters, of the physical screen.
NUMFONTS Number of device-specific fonts. Use printer matched fonts if possible (though most are good anyway).
ASPECTX Relative width of a device pixel used for line drawing.
ASPECTY Relative height of a device pixel used for line drawing.
ASPECTXY Diagonal width of the device pixel used for line drawing
PHYSICALWIDTH For printing devices: the width of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper has a physical width value of 5100 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller.
PHYSICALHEIGHT For printing devices: the height of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper has a physical height value of 6600 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller.
PHYSICALOFFSETX For printing devices: the distance from the left edge of the physical page to the left edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper, that cannot print on the leftmost 0.25" of paper, has a horizontal physical offset of 150 device units.
PHYSICALOFFSETY For printing devices: the distance from the top edge of the physical page to the top edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper, that cannot print on the topmost 0.5" of paper, has a vertical physical offset of 300 device units
If your using the CPrintDialog then LPDEVMODE GetDevMode( ) will get you all the information you want in one go.
But the point is, that you must scale to printed page in much the same way as you do for the screen and each of its modes.
Experiment with the DEVMODE structure, what you will find is that you can scale text/graphics by the pel size, so that with a function such as
(xpos-ypos in mm or points)
PrintMyTextOnPaperAndBanLongFunctionNamesToo(xpos,ypos,LPCTSTR Text)
You can get accurate printing to 1/10th mm
We do it for the joy of seeing the users struggle.
|
|
|
|
|
the control won't show up when I execute my program in other computer..
why ??
|
|
|
|
|
Is the ocx in that computer?
Is the ocx registered in that computer?
(When the ocx is not in the computer, o is missing some componnent, or the ocx is not registered, the componnet not appear)
Best Regards
Carlos Antollini.
|
|
|
|
|
please answer the question:
how can i move control with mouse on the dialog but without drag&drop?
|
|
|
|
|
First capture the notifications from the mouse on the desired control, then move the control to the position of the mouse using MoveWindow.
To redraw the movement of the control while the mouse is moving capture the WM_MOUSEMOVE and move the control accordingly.
See:
CWnd::MoveWindow
WM_MOUSEMOVE
WM_LBUTTONDOWN
WM_LBUTTONUP
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
How do I go about displaying Windows Explorer style forlder view without control panel, printers and recycle bin, but only to include drives (hard disks, floppy disks and CD roms) and directories with correct icons. Is there a system property does assosiates icons to device types?
Please help,
Tushar
|
|
|
|
|
Hello,
Sorry if this is a repleat type question.
I have been using this site to learn more about WTL and there is very useful information included. I am trying to develop a FormView type application that has a toolbar + statusbar + dialog type form view. When I create such an application with WTL app-wiz, I do not get scroolbars the way MCF app-wiz does and therefore if I resize the eventual application, I cannot scroll which you can imagine causes a problem.
Next question, it is possible to display menus in MCF application with icons, like WTL apps do? I do not want to incorporate large amounts of code into my app that is not tested. This way I would not have to use/learn WTL.
Please help,
Tushar
|
|
|
|
|
After i compiled my project in the release version and execute my program in other computer, there is an erros msg says "An unsupported operations was attempted".
I think the one causing it is my MFC 2.0 GridControl
What can I do ???
|
|
|
|
|
I don't know where the gridcontrol resides (comctr32?), but it seem like
you either don't have the module on the testcomputer, or it is not registred. Check version for whatever module gridcontrol resides in, and try to (re)register it using regsvr32.
/moliate
|
|
|
|