|
I've been playing with ADO a bit lately and I've found that if you pass in a bad string, it crashes, and crashes HARD.
if(FAILED(m_pRs->Open("SELECT * FROM employeer",_variant_t((IDispatch*)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText)))
Is 'employer' spelled wrong in the database as well ? If not, a typo here would cause a crash every time, and not a graceful or easily traceable one.
I'd also suggest it is poor form to name local variables m_, that indicates a member variable ( one declared in your header file and therefore visible to the entire class ).
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Do you need to end a statement with a ';' too? as in,
<br />
pCommand->CommandText = _bstr_t("SELECT `tblImages`.* FROM `tblImages` WHERE `tblImages`.`visitID` = `param1`;");<br />
|
|
|
|
|
No, I don't believe so ( the code is at home so I cannot check, but I don't think SQL wants a ; ).
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
No,I means when I click the "Try" button again,the wrong message appeared,while when I first clicked the "Try" button,everything is OK.
I tried to change my code with an other way such as:
CFirstDialog::OnButtonTry()
{
CTestDialog dlg;
dlg.DoModal();
}
It's still wrong.
Because I use Chinese,so the error message was showed in Chinese,I only know the error number is 0x80004005,what it means?
|
|
|
|
|
The following code will translate an error number for you
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
0x80004005,
0,
(LPTSTR) &lpMsgBuf,
0,
NULL
);
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
In this case it is 'unspecified error', which is what ADO always seems to give ( but it could well come from elsewhere all the same ).
Changing your code as you have done is obviously a step forward, no need for a pointer, plus an ugly memory leak. You should do the same for your FileDialog, or at least delete the thing if people press cancel.
Are you trying to run in F5 ( debug ) mode ? Are you pressing cancel and letting the debugger show you where it is crashing ? If the above code is crashing ( just a domodal() call, then it's dying in the dialog code, and I would continue to maintain in your ADO code. You should set a break point and step through the OnInitDialog as a first step. Are you closing your connection to the database ? It may well be crashing the second time because your first connection is still open.
Also your database path is not absolute, if something else in the dialog is changing the current directory, that will also mean it cannot find the file and will crash.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thanks,you're right.
When I open the "Open/Save File Dialog",it changed the current directory.
It cannot find the database,so the wrong message appeared.
Thanks again.
|
|
|
|
|
Glad to help ADO was a nightmare for me in the first little while because it crashes so easily and my books are filled with examples which simply do not work.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Good day,
Why would this not fill the complete rectangle specified by rcHighlight? this is for a Multiline(per item) ListCtrl and in the DrawItem function.
CRect rcHighlight = GetItemRect(lpDrawItemStruct->itemID, rc);
rcHighlight.left += 1;
rcHighlight.top += 1;
rcHighlight.right -= 1;
rcHighlight.bottom = rc.bottom - 1;
if (lpDrawItemStruct->itemState & ODS_SELECTED) {
pDC->FillSolidRect(rcHighlight, GetSysColor(COLOR_HIGHLIGHT));
pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT)) ;
} else {
pDC->FillSolidRect(rcHighlight, GetSysColor(COLOR_WINDOW));
pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT)) ;
}
I've verified that the rectangle is the correct rect and size but yet FillSolidRect only fills half of it. Any help is greatly appreciated.
Bret Faller,
Off-Duty programmer
|
|
|
|
|
You often have to add +1 to right and bottom. Also, line drawing does never include the last coordinate. Takes some to get used to.
|
|
|
|
|
check that nothing has set a clipping region on that DC (if you can)
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Thanks for your response...how might I go about checking if something else has set the clipping region? I've looked into somem of the clipping functions but I'm actually not to familiar with the CDC. Thanks again for your response.
Bret Faller,
Off-Duty programmer
|
|
|
|
|
I might be barking up the wrong tree in the wrong forest here, but:
CRect rcHighlight = GetItemRect(lpDrawItemStruct->itemID, rc);
rcHighlight.left += 1;
rcHighlight.top += 1;
rcHighlight.right -= 1;
rcHighlight.bottom = rc.bottom - 1;
Looking at the prototype for the GetItemRect Function:
int GetItemRect( int nIndex, LPRECT lpRect ) const;
The return value is just a status code. lpRect is where the rect comes in. But, your code uses a CRect rcHighlight for a return value ?!?! and you adjust it's size a little, and then draw it.
Also, the fourth line of your code sets rcHighlight.bottom to rc.bottom, whereas the others just adjust the size of the incorrectly filled CRect object.
I don't know, maybe you just mistyped the code into the discussion forum?
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Actually its my own custom GetItemRect function because this is for a multiline ListCtrl that I am making and it determines the size of the row based on how many lines of text the biggest subitem has. It takes the itemid and the original rect of the item which comes from the DRAWITEMSTRUCT in my DrawItem function and then it inflates it based on how many lines of text are in the biggest subitem. Thanks for your response though.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
In my Win32 app I have a hidden window and all other windows are a child of it. Actually for this to work I had to *show* the window, so it's at -20, -20 and is 1x1 pixel wide. I've tried making it on screen and bigger, it does not solve the following problem.
The app has a console that accepts Python commands and an indeterminate number of other windows, as they can be dynamically created in Python. So I do the following:
LRESULT CALLBACK MainProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_SETFOCUS:
::SetWindowPos(console, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
::SetWindowPos(hDlg, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
break;
case WM_KILLFOCUS:
::SetWindowPos(console, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
break;
case WM_CLOSE:
PostQuitMessage(0);
break;
}
return FALSE;
}
in my main window in order to keep the Console above all the other windows. I've tried commenting out this code as well, it does not help. The problem is that right clicking on the taskbar button does not bring up a menu. Can anyone suggest how I can fix this ?
As an aside, I presume it's possible to add to this menu ? Does anyone know how ? I've done Explorer menu shell extensions, but I am not sure if the taskbar menu can be added to the same way.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
> The app has a console
This is just an input window, acting as a console, not an AllocConsole window, right?
> The problem is that right clicking on the taskbar
> button does not bring up a menu. Can anyone
> suggest how I can fix this ?
Ahh, the beauty of windows.
I suspect the window coordinates for your topmost window.
Have you tried to make your "parent" window (really the "owner" window) "invisible" (WS_INVISIBLE) at (0,0)-(1,1). This is how MS solves it IIRC.
As for adding to the taskbar menu, I think you have to 1) "inject" your DLL (I believe you know this or where to find it, MSDN) and then lookup the window class "SysTabControl32".
++luck
/Mike
|
|
|
|
|
Thanks for the reply.
Yes, it's a dialog box, not an actual console window.
I've tried making the co-ordinates such that the window is physically onscreen, it does not help. Or do you mean the co-ordinates of my console ( which is the topmost window ) ? How would that affect things ?
Also, I have the latest SDK ( well I own it and I *think* I have it installed ) and WS_INVISIBLE is not recognised. The latest MSDN also does not find it. Am I missing something, because WS_INVISIBLE sounds like just what I've been looking for.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
> I've tried making the co-ordinates such that
> the window is physically onscreen, it does not
> help. Or do you mean the co-ordinates of my
> console ( which is the topmost window ) ?
Yes, I intended the top-most window.
I suspected that since the "owner" window (the top-most window as I understand it) is outside the visible area, there might be some wrap-around or other errors (negative window coordinates on (0,0)-(x,y) screen).
But I'm not surprised you didn't find the WS_INVISIBLE, it doesn't exist. I was taking that from the top of my head, and apparently that head was somewhere in the blue.
WS_EX_TRANSPARENT was the windows style I was thinking of.
To see where your mouse messages go, try Spy++. It will be lots of mouse messages, but perhaps you can see where the RMB clicks are going?
/Mike
|
|
|
|
|
Hi all,
I have an application that is a MDI app, with multiple views attached
to each document. When I switch between views of the same document,
with the MDI child frames NOT maximized, everything is cool (no
flickering when switching between frames/views). However, when I
switch between frames when the child frames are MAXIMIZED, the
activated frame/view seems to "remember" it's non-maximized
dimensions, display that and THEN subsequently refresh and display
itself as maximized. As you can guess, this causes a momentary
flicker in between the time the maximized frame shows the
"non-maximized" dimensions and the the time it finally displays itself
as maximized. Any clues as to how I might avoid this?
Thanks....
|
|
|
|
|
First of all.. I'm new to MFC
In my mdi app I have a class which derives from CRichEditView. Since I want to be able to use the extended capabilities of Rich Edit 2.0 I added this to my class.
BOOL MyTextView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
CCtrlView::m_strClass = "RICHEDIT_CLASS";
return CRichEditView::PreCreateWindow(cs);
}
This works fine except from when I try to create the window. The call to CreateWindowEx in CWnd fails, GetLastError returns 0 and I get the message that an empty document couldn't be created. It's feels like I'm on the right track but I have no idea what to do next
/Eric
|
|
|
|
|
|
I'm not sure how much work is involved here, but I'm trying to get a What's This (context sensitive help) button on the titlebar of a tool-style modeless dialog. i.e. I've removed the WS_EX_APPWINDOW style and added the WS_EX_TOOLWINDOW style to prevent the dialog from showing up in the taskbar. I've also added the WS_EX_CONTEXTHELP style to enable context sensitive help. The relevant line of code is in my dialog's OnInitDialog handler:
ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW | WS_EX_CONTEXTHELP, SWP_FRAMECHANGED);
I get help messages when a control on the dialog has focus and I hit F1, but the ? button on the titlebar is not drawn. It appears that the tool window style precludes the drawing of any buttons except the close button, but I haven't found any doc to support or refute this.
So my question is: has anyone figured out a way to "force" the drawing of the help button? I'd like to avoid custom painting and messaging code if possible, but I'll do what I need to.
Thanks,
Steve
|
|
|
|
|
Hey all!
I used ATL to develop an ActiveX control.
This control has it's own window (doesn't support Windowless operation).
I tried to add a message handler for the WM_KEYDOWN message and its friends, but my window doesn't receive those messages.
I also subclassed the rich edit control I use there for text (it would be sufficient for me to capture the key strokes that reach it) - but I want to capture Ctrl+B, Ctrl+I, Tab, Shift-Tab and Ctrl+F4 messages - and ALL of those key pressed are not even sent to the rich edit control - IE intercepts them and acts as if they were sent to IT!
What can I do?
Thanks!
|
|
|
|
|
I've got a COM addin DLL written in VB6 for Outlook2000 that makes calls into an MFC regular DLL written with VC++6. On both WinNT and Win2k this works fine. However when trying to run the application on a Windows 9x machine the VB6 part of the application works fine up to the point where it attempts to make the call into the VC++ DLL. I believe I have all the necessary dependencies copied to the proper location on the Win 9x machine and I am not using any NT specific code so I am stumped as to why this will not work. Anybody have any ideas for me?
|
|
|
|
|
Do you have any idea at what point its having the problem exactly, and if so, what does the code look like?
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
It's having the problem when the Visual basic DLL attempts to make the call into the VC++ DLL. For some reason this call is not taking place on the Win9x machine, but on the NT/2k machine it works fine.
The visual basic declaration of the VC++ dll function looks like this:
' Declare VC++ DLL function import
Declare Function IndexMsg Lib "OL_Index" Alias "IndexMessage" (ByVal msg_path As String, ByVal msg_note_path As String) As Integer
The actual call to this function looks like:
' Call VC++ DLL function to start the import process
result = IndexMsg((temp_path + MAIL_NAME), (temp_path + MAIL_NOTE_NAME))
On the VC++ side of things, the function declartion looks like:
extern "C" UINT IndexMessage(LPSTR msg_path, LPSTR msg_note_path);
And the implementation like:
extern "C" UINT IndexMessage(LPSTR msg_path, LPSTR msg_note_path)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// debug call to see how far the call goes
AfxMessageBox("Made it into Index func!", MB_OK);
// call the function to perform the indexing tasks
return theApp.DoDisp(CString(msg_path), CString(msg_note_path));
}
And finally my .DEF file for the VC++ DLL exports looks like:
LIBRARY "OL_Index"
DESCRIPTION 'OL_Index Windows Dynamic Link Library'
EXPORTS
; Explicit exports can go here
IndexMessage @59 PRIVATE
|
|
|
|
|