|
That line crashes because (_bstr_t)pStr creates a temporary _bstr_t object which then gets deleted right away. That leaves records->Filter pointing at invalid memory. (This assumes records->Filter is a BSTR or other pointer type.)
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
It's a _variant_t, but even if I create the _bstr_t seperately, it still crashes. I am certain it crashes because ADO does not recognise the command as valid, even though the syntax is the same when I pass in a hard coded value and it works.
_bstr_t s = pStr;
records->Filter = s;
Crashes
_bstr_t s = "FilePath = 'f:\\bibloi1.mdb'";
records->Filter = s;
works, even though the string I bring up in a MessageBox ( pStr) is exactly the same.
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'm guessing you've already tried this, but maybe a little sanity check is in order;
_bstr_t s = pStr;
_bstr_t s2 = "FilePath = 'f:\\bibloi1.mdb'";
if ( s == s2 ) {
MessageBox ( "They are the same!!!");
}
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
It would appear the ADO error only occurs if there are spaces in the field. How do I get around that ? I've put them in quotes (tried single AND double)...
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.
|
|
|
|
|
You have probably already figured this out, but if your DB allows spaces in field names (e.g. Access) most impls I've seen (i.e. Access) want you to surround them with [] brackets.
Careful though - SQL Server (which doesn't allow spaces, AFIK) will err out on you if you try to add the [].
It may be almost a rule of thumb that if you retrieve a field or table name that has an 0x20 in it you should slap the []s on 'em, and let 'em go otherwise.
|
|
|
|
|
Hi,
the explanation why
sprintf(pStr, "FilePath = '%s'", (_bstr_t)bstrPath);
doesnt show the expected result is that reference types doesnt work with va_args (functions with variable number of args - ellipsis). You have to explicitly cast via (LPCSTR) or better use _stprintf( buf, _T("<format string="" here="">"), (LPCTSTR) reference_type, ...); for supporting both unicode and ansi versions.
KB id: Q119394 convers this problem and another possible (nonportable) solution.
Cheers,
A. Focht.
|
|
|
|
|
I can't seem to get the GetMenuItemInfo function to work.
Here's my code, please tell me what I'm doing wrong.
HMENU hMenu = CreateMenu();
HMENU hPopupMenu = CreatePopupMenu();
::InsertMenu(hPopupMenu, 0, MF_STRING | MF_BYPOSITION, 0, "My PopupMenu");
::InsertMenu(hMenu, 0, MF_POPUP | MF_BYPOSITION, (UINT)hPopupMenu, "My Menu");
::SetMenu(GetSafeHwnd(), hMenu);
MENUITEMINFO mii;
memset(&mii, 0, sizeof(MENUITEMINFO));
mii.fMask = MIIM_STATE;
if(::GetMenuItemInfo(hMenu, 0, FALSE, &mii))
{
mii.fMask = mii.fMask | MIIM_STATE;
mii.fState = MFS_CHECKED;
::SetMenuItemInfo(hMenu, 0, TRUE, &mii);
}
else
AfxMessageBox("Err!");
|
|
|
|
|
You didn't set the cbSize member of MENUITEMINFO.
mii.cbSize = sizeof(MENUITEMINFO);
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
There is an article listed here:
http://www.codeproject.com/listctrl/emptylv.asp
and an identical article with more comments listed here:
http://codeguru.earthweb.com/listview/EmptyLV.shtml
I have a CFormView with 2 CtrlList in there. I can't implement either article. I just want it an empty CtrlList to print somethign that tells the user it's empty right now.
By chance, can someone, anyone make this work? Please, any response any one can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
What I do is write a custom draw handler, and in the CDDS_PREPAINT stage, if the list is empty, call TextOut() to display "There are no items to show" or whatever message you want.
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
Hello,
How can I resize my dialog height to fit the screen - the taskbar when someone drags it to the edge of the screen? I don't want all the specifics just some explanation. Currently I have a dialog that snaps to the screen border and when it snaps to the screen edge I use SetWindowPos(NULL, 0, 0, rc.Width(), rcDesktop.Height() - bottomTaskbar, SWP_NOMOVE|SWP_NOSENDCHANGING); but it keeps resetting it back to its normal size after I call that... any ideas? Thanks in advance.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Type A:
// the following code is OK
CFileFind l_Blah;
l_Blah.FindSomthing("c:\\dir123\\*.abc");
while (l_Blah.FindNextFile())
{
l_Blah.GetFilePath();
}
Type B:
// and the following code is NOT OK
CFileFind l_Blah;
CFileFind l_Blah;
l_Blah.FindSomthing("c:\\dir123\\*.abc");
l_Blah.GetFilePath(); // <--- this line makes an error
while (l_Blah.FindNextFile())
{
l_Blah.GetFilePath();
}
if I use Type A, I always lose the first file that found.
What can I do????????????
Name: STR
BTW: for some of you that wished for CodeProject irc server
I create a channle on DalNet called "#CodeProject"
|
|
|
|
|
You need to do it something like this
CFileFind finder;
BOOL bContinue = finder.FindFile("bla.bla.bla");
while (bContinue)
{
...
finder.GetFilePath();
...
bContinue = finder.FindNextFile();
}
|
|
|
|
|
I need to correct something
CFileFind finder;
BOOL bContinue = finder.FindFile("bla.bla.bla");
while (bContinue)
{
...
finder.GetFilePath(); <=You will have a crash here.
...
bContinue = finder.FindNextFile();
}
this is the correct mode.
CFileFind finder;
BOOL bContinue = finder.FindFile("bla.bla.bla");
while(bContinue)
{
...
bContinue = finder.FindNextFile();}
finder.GetFilePath();
...
}
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
Hello,
Is it possible to rotate a dialog completely (title bar and all)? Say I want to tilt the dialog onto its side, possible? How? Thanks.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Hello,
I am tracking the TME_LEAVE mouse event in my dialog based app but even if it still has focus and I move the mouse to the listbox control then this message fires. Is there anyway to have it work like a "real" leave, say when it leaves my app? Any help is greatly appreciated.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
What would be the best way to pass a callback function to a DLL? I want to do something like this:
In the Dll...
BOOL declspec(dllexport) __stdcall InstallKeyboardHook(HOOKPROC proc)
{
g_hKeyboardHook=SetWindowsHookEx(WH_KEYBOARD, proc, g_hInstance, 0);
return g_hKeyboardHook ? TRUE : FALSE;
}
In the executable, after LoadLibrary and GetProcAddress...
InstallKeyboardHook(MyHookProc);
LRESULT CALLBACK MyHookProc(int code, WPARAM wParam, LPARAM lParam)
{
MessageBeep((UINT)-1);
}
I don't get any errors, but I don't get any beeps from key presses, either. HELP!!!!
Thanks in advance.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
if you want to catch the WM_KEYDOWN or WM_KEYUP before the message is sent to any other window,
Change:
BOOL declspec(dllexport) __stdcall InstallKeyboardHook(HOOKPROC proc)
To:
BOOL declspec(dllexport) __stdcall InstallKeyboardHook()
I guess that YourHookProc is in the executable file, when it should be in the dll.
In the executable,
you should call only InstallHook() and UninstallHook();
BTW:
you should here beep if you hit a key when the thread is on focus.
try creating a MessageBox under the same thread that called InstallHook(...) and hit space when the message box is open.
DONT FORGET:
Turn on you speakers
Let me know if I helped you.
I did this kind of app, but insted of beep I used the ICQ's MsgType.wav
if you want to check it out, let me know
Name: STR
BTW: for some of you that wished for CodeProject irc server
I create a channle on DalNet called "#CodeProject"
|
|
|
|
|
The hook function (MyHookProc) needs to be in a DLL if it's a global hook.
> Andrew
"Do you like my mask, it raises the dead...!"
-- Buffy (season 3, Giles)
|
|
|
|
|
when creating the thread function that gets passed to the AfxBeginThread() function, does this function have to be a global function or can it be say a function of a View/Doc class ... or does it matter???
Bryan ~
|
|
|
|
|
It can be a global function or a static member function of a class. However, you can fake a normal member function by passing the address of an object to the thread function, and then use that to access the members of the object.
Hope that helps,
> Andrew
"Do you like my mask, it raises the dead...!"
-- Buffy (season 3, Giles)
|
|
|
|
|
I have a project that I'm working on and I need the background of my SDI (using VC++ and MFC) to be white but I can't seem to figure out how to do this ... any sugestions??
Thanks -
|
|
|
|
|
You should be able to use something similar to the folowing;
BOOL CYourView::OnEraseBkgnd ( CDC * pDC ) {<br />
<br />
CBrush brush;<br />
brush.CreateSolidBrush ( RGB ( 200, 0, 0 ) );<br />
<br />
CBrush * pOldBrush = pDC->SelectObject ( &brush );<br />
<br />
CRect rect;<br />
GetClientRect ( &rect );<br />
pDC->PatBlt ( 0, 0, rect.Width (), rect.Height (), PATCOPY );<br />
<br />
pDC->SelectObject ( pOldBrush );<br />
<br />
return 0;<br />
}
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Hello,
I have a ListView class, displayed in report mode. How can i change the font of the text displayed in columns and header.
Thanks.
Regards,
Ganesh.M.Ramaswamy
|
|
|
|
|
You can do it with the custom draw feature that ListView controls have. Search your docs for the NM_CUSTOMDRAW notification message to get the details.
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|