|
First, I have never used the DAO classes (I typically use CDatabase/CRecordset for simple stuff and ADO for anything else). So I cannot address issues relatiing to DAO specifically. There may be easier techniques for you to use than what I am suggesting for DAO built into MFC. If you look at MSDN or Codeproject samples you might find something relating to that.
Yes, DoModal returns when the dialog box is closed. That is by design, and is typically the behavior you want. Obviously, I don't know the details of your design, and maybe what I'm suggesting will not work for you. All I'm saying is that it is the approach I *always* take, as I have found it to be a very safe and simple way to do business, especially in a large application that many people have their hands on.
What I am suggesting is that you copy the data that you want to manipulate from the db object, which is "owned" by the MainFrame object, to the dialog box, initializing the dialog box with that data (there are various opinions about how to do that best). Next you allow the user to manipulate that data in the dialog box. Finally, if the user hits OK you copy the edited data from the dialog box and back to the db object, if the user hits cancel, do nothing at all.
In this way, the dialog box never needs to know that the db object even exists, and the db needs to know nothing about the dialog. Only the Mainframe window (and the db object itself, of course) knows, or cares, about the db object, or the dialog. In this way, the db object, and whatever global data it contains, is not made public to the entire application unnecessarily.
If the db data also needs to be accessed from objects other than dialogs, (views, for example), than that might be an argument for giving ownership of the db object to your document class rather than the Mainframe. If more than one document/view needs access to the db data, well, than you might need to consider letting the App class handle it afterall. As the programmer, its your call.
|
|
|
|
|
I want to use CGfxOutBarCtrl class, but I need to display an icons with variable width (height is permanent) in it.
All icons are adding via CImageList but it stretch all of them to the maximal size.
Do you have any ideas how to display such type of icons there?
With the best regards, Vitaly.
|
|
|
|
|
You would have to use two, or more, imagelists. As you found out everything in the imagelist must be the same size, that is how individual images are found, by calculating the offset based on the size.
|
|
|
|
|
i would use the ADodb method to create a link between an vc++ application and Access 97. what is the correct microsoft jet OLEDB i need to use, 4.0 or 3.51?
gerald
|
|
|
|
|
Access97 uses 3.51, but 4.0 should be backward compatible.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I have editBox (read only) with spin.
the variable of the editBox is int in range 10 - 2000
and the range of the spin is same.
and all is right.
But when the user try to up the number in the editBox over 999
he gets a error messageBox: "Please enter an integer."
WHY ?????????????????????????????????????????????????
Please HELP
|
|
|
|
|
Uncheck the No Thousands property of the spin control - this prevents the control from adding a thousands separator (period or comma) to the number.
--Mike--
http://home.inreach.com/mdunn/
Push the button, Frank.
|
|
|
|
|
Thanks on the quickly answer !!!
|
|
|
|
|
I have gray the desktop, but there still some area cannot be grayed, how can I gain this effect.
I use CreateDIBSection. and BitBlt to copy the memory dc to the desktop.
|
|
|
|
|
I have try to gray the desktop when my program runs. by there are still some problems:
1, If I use CreateDIBSection, What bitsperpixel should I use, 8, or >8?
2, If I can use 32bits, even on 16 desktop settings?
|
|
|
|
|
hi.. I wanna open a folder from my software...Can i do that??????
|
|
|
|
|
I don't know exactly what you mean, but try looking up
SHBrowseForFolder in the MSDN Lib
maXallion "Look for bugs, I hate bugs!" - Warden, The Mummy www.maxallion.de - coded evil & more
|
|
|
|
|
I have two different times on my box...In VC++ the time says "1:40" and in the System Tray it says "8:40"?? Even when I write a program using the System time in VC++ I get the C++ time and NOT the actual System Time??
Settings:
Region(Locale)/Keyboard: U.S.
Time Zone: Germany (-1)
The funny thing is this is the Time (-7 hours) as our Mother Company in the US. I hope someone can show where the problem is.
Thanks in advance,
Dan
|
|
|
|
|
You don't say what function you use to get the time, but if you use time(), you have to convert the time with localtime() to get the local time...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Does anybody know the way to get rid of the thick (client?) border around the edit portion of combo box? Regular methods (that work with other controls) seem to have no effect.
Trying to make a property list control.
Thanx,
Dejan,
Melbourne
|
|
|
|
|
The example of a code, which one is fine draws on a screen, but is absolutely failed to print (except for a framework of an rectangle).
CTestView::OnDraw(...)
{
CBitmap m_bitmap;
m_bitmap.LoadBitmap(IDB_ ...);
CBrush m_brush;
m_brush.CreatePatternBrush(&m_bitmap);
CBrush * pSysBrush = pDC->SelectObject(&m_brush);
pDC->Rectangle(0, 0, 300, 300);
pDC->SelectObject(pSysBrush);
}
How to make correctly?
|
|
|
|
|
When you print you'll be working with a much bigger DC than on the screen. It probably printed a dot somewhere near the top. You need to query the printer DC to find out it's size and then scale the bitmap accordingly.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I want to add a Capture Video ActiveX in my program.
When I add the ActiveX in my mainframe (CMyAppDlg) and that I use the associated functions with this activeX, I don`t have any problem.
But I want to add this ActiveX in a modeless windows created by a item menu. The problem is when I include this ActiveX in my modeless windows and that I call the associated functions to the ActiveX, I have a Assertion Error: "Debug Assertion Failed!" in the file "Winocc.cpp" for each call of a function of this ActiveX.
So, I don't know why the ActiveX work in my mainframe but doesn't work in the modeless Windows since I use the same code in the two manner?
Thanks for your help!
Francis B.
|
|
|
|
|
I'm having the same problem with a different ActiveX control I'm using
in a modeless dialog from within a DLL. For some reason it seems as though
the ActiveX control is not being created properly during the call to
Create(). Mine always has a NULL hWnd after the call to create so whenever
a method on the control object gets called it bombs out with that same
assertion error you're getting because the control has actually not been
created properly. I wish I had a solution for you, this one is driving
me crazy!
|
|
|
|
|
Alright, I have created an SDI app and, using Navigate2() have loaded a page. I have used the OnDocumentComplete() to allow me to know when it is done loading. How can I get the source code for that page?
Thanks!
Adam
cabadam@houston.rr.com
|
|
|
|
|
CComPtr<ihtmlelement> m_pBody;
CComPtr<iwebbrowser2> spBrowser;
HRESULT hr = QueryControl(__uuidof(spBrowser), reinterpret_cast<void**>(&spBrowser));
if( SUCCEEDED(hr) )
{
CComPtr<idispatch> pDisp;
if( SUCCEEDED(spBrowser->get_Document(&pDisp)) && pDisp )
{
HRESULT hr = pDisp.QueryInterface(&m_pDoc);
if( SUCCEEDED(hr) && m_pDoc )
{
if( SUCCEEDED(m_pDoc->get_body(&m_pBody)) && m_pBody )
return TRUE;
}
}
}
return FALSE;
|
|
|
|
|
CComPtr m_pBody;
But... isn't CComPtr a templated class? What would I use as the template type?
Adam
cabadam@houston.rr.com
|
|
|
|
|
Hi.
Does anyone know of a way to emphasize or highlight specific items in a list box, and/or in the list portion of a combo box?
eg: The list box contains a number of items, all of which must be visible, but only some of which are "valid" selections for the user (invalid items can be selected, but have different effects). I need a visible difference between valid & invalid choices within the box (different text color, check mark, etc).
I would rather not get into owner drawn, since that is completely new to me.
Thanks.
Wayne Janaway
|
|
|
|
|
|
I need to copy entire directory including subdirectories and files to
some destination. What is easiest way to do this?
Bad judgement gives Good experience;
Good judgement comes with Bad experience
|
|
|
|