|
Ok, I'm a beginning MFC user so I'm probably just doing something stupid...
Anyway, I added class members for my list boxes using the Class Wizard window. Anytime I try to do anything with them in the OnInitDialog() function I get an assertion error because I think my list box members aren't initialized or something. Is there anything i have to know about using them? Do I have to do a data exchange before I use them or something, or somehow initialize them?
|
|
|
|
|
You must call DoDataExchange() once to hook up your member variable to the control. CDialog::OnInitDialog() does this, so put your code after the base class function call.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
Hi there,
I was wondering how you create an application that has a little icon on the
bottom right hand side...kind of like Real Player or McAfee or so many other
application that have that little icon in the bottom right hand side of Windows,
which you can click to launch the application dialog.
thanks
|
|
|
|
|
Hello, the codegurus around the world.
Check Master Chris Maunder's code.
http://www.codeproject.com/shell/systemtray.asp
(Acutally, I'm looking for the codegurus web site, but I couldn't find his code. )
I remembered that he posted his code at codegurus about two and half years ago.
He commented in those days that he can't believe that some company gets the money
from this kind of codes.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Hello,
I got a small problem (or rather question)...
global:
-------
SHGetDesktopFolder(&m_pShellFolder)
// the nFolde value can be diffrent,, also CSIDL_DESKTOP.. depends what button user press
SHGetSpecialFolderLocation(NULL, nFolder, &m_ppidl);
func:
-----
IShellFolder* pFolder;
IEnumIDList* pEnumIds;
if (::GetSize(m_ppidl) == 2)
{
// if the user is in the root path (desktop folder) do this...
m_pShellFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &pEnumIds);
pFolder = m_pShellFolder;
pFolder->AddRef();
}
else
{
// if the user is in a folder that is BELOW the desktop do this.... the pidl is
// a full path list in both cases (ie it holds the desktop id as first entry)
m_pShellFolder->BindToObject(m_ppidl, NULL, IID_IShellFolder, (LPVOID *)&pFolder);
pFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &pEnumIds);
}
// after this the enumaration process starts and I use pFolder->GetAttributesOf
// and pFolder->GetDisplayNameOf...
.
.
.
pFolder->Release();
I got this code. Anyway as you might notice I do pFolder = m_pShellFolder.
My question is, can this be dangerous when I do pFolder->Release(); since both pointers point at the same memloc...?
(SIDENOTE)
If GetSize returns 2 I assume that the pidl tells you that your in the root (DESKTOP)
else your in a subfolder to the root
, my code is supposed to add to the pidl list as the user goes down in the folder structure..
(THE QUESTOIN )
So my question is, as I said, is it safe to do pFolder = m_pShellFolder; and then release pFolder later with pFolder->Release()?..
Will this destroy m_pShellFolder (or make it unusable) (it worked tough i dunno if its safe?)?
What im trying to accomplish is basicly to get a copy of the m_pShellFolder structure(the one it points at) to a new IShellFolder object..
I hope someone understood this
Cheers,
Henrik
|
|
|
|
|
You're doing exactly what you should be doing. Calling AddRef() tells the underlying COM object that there is a new reference to it. Just remember to call Release() through both pointers to properly clean up.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
Does anybody know of any good examples of how to use Visual C++ to program an Add-In for the Visual Basic IDE? In VB, you'd add references to the MS Office and VB Extensibility models in the reference dialog, then add the line
Implements IDTExtensibility to your 'Connect' class. Fairly straight forward. How can I do this using Visual C++?
Thanks in advance for any help.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
there a book on ado in vc? (not vb)
|
|
|
|
|
Check out "Visual C++ 6 Database Programming Tutorial by Wendy Sarrett, ISBN 1861002416.
More detail on Wrox's website at http://www.wrox.com/Books/Book_Details.asp?sub_section=1&isbn=1861002416&subject=C%2B%2B%2FVC%2B%2B%2FC%23&subject_id=3
Hope this helps...
TEF
|
|
|
|
|
www.informit.com
online book called "Sams Teach Yourself Database programming with Visual C++ in 21 days" or something like that is available there...
Get ready for lots of cursing at those VB programmers with their full automation support...
couple of MSDN articles are essential here:
"Visual C++ ADO Programming" in ADO Appendices
"Using Visual C++ Extensions" in "
|
|
|
|
|
In my current project I have to run a procedure at a specific time during the night. For this I am using the "SetWaitableTimer" function (see code below).
This code runs perfectly on a Win2K machine. But on a Win98 machine, it looses 3 Seconds per minute. ie. If I start it at 12 Midday to run at 12 Midnight (12 Hours difference) then the scheduler will run 36 Minutes late.
Any help at all would be usefull.
Joe.
[Code]
HANDLE hScheduleTimer;
bool CCashierLogon::StartScheduler()
{
...
hScheduleTimer = CreateWaitableTimer(NULL, FALSE, NULL);
if (hScheduleTimer != NULL)
{
SYSTEMTIME sysSch; //24/Apr/2001 00:00:00
sysSch.wYear = 2001;
sysSch.wMonth = 4;
sysSch.wDay = 24;
sysSch.wDayOfWeek = 0; //Ignore
sysSch.wHour = 0;
sysSch.wMinute = 0;
sysSch.wSecond = 0;
sysSch.wMilliseconds = 0; //Ignore
FILETIME ftSch, ftUTC;
LARGE_INTEGER liSch;
SystemTimeToFileTime(&sysSch, &ftSch);
LocalFileTimeToFileTime(&ftSch, &ftUTC);
liSch.LowPart = ftUTC.dwLowDateTime;
liSch.HighPart = ftUTC.dwHighDateTime;
long lPeriod = (1000 * 60 * 60 * 24); //Every 24 Hours
if (SetWaitableTimer(hScheduleTimer, &liSch, lPeriod, NULL, NULL, FALSE) == TRUE)
{
CWinThread *pSchThread;
pSchThread = AfxBeginThread(MainScheduler, //Function Name
(PVOID)hScheduleTimer, //Handle
THREAD_PRIORITY_NORMAL, //Normal
0, //Stack Size
CREATE_SUSPENDED); //Create Suspended
pSchThread->m_bAutoDelete = FALSE;
pSchThread->ResumeThread();
}
}
...
}
UINT MainScheduler(LPVOID pParam)
{
HANDLE hSchedule;
hSchedule = (HANDLE)pParam;
while(1)
{
if (WaitForSingleObject(hSchedule, INFINITE) == WAIT_OBJECT_0)
{
//
//Do Our Midnight Processing Here...
//
}
}
return 0;
}
|
|
|
|
|
Hi:
When I run the my program in one computer it gives an error saying Unhandeld exception in ... :0xC0000005 Access Violation, but suprisingly, the program works fine in two other computers?
Please help if you know how to handle the problem, I really appreciate your comments.
thank-you
|
|
|
|
|
Assuming its a release mode app and you can't debug on the machine in question, one thing that can help is to create a map file when you compile (see the Link tab of the project settings). Once you have a map, you may be able to identify the function (though not the line) of your code where the crash is happening from the address given in the message, and this can be helpful.
Could be data related - a string that is fine on some machines/data sets is NULL on the problem machine, and code is not checking it before passing it to strlen etc.
Check http://support.microsoft.com/support/kb/articles/Q196/7/55.ASP for more info.
|
|
|
|
|
I wrote the following code in my app. It works fine but a bunch of warning messages
are bugging the hell out of me. All the books that I consulted declare map like this.
Any help to get rid of these obnoxious warnings is much appreciated. Thanks.
class Product
{
........
}
int main()
{
Product Pen("Pen", 5.99, 58);
Product Lamp("Lamp", 28.49, 24);
Product Speaker("Speaker", 24.95, 40);
map<std::string, product=""> productMap;
productMap[Pen.getName()] = Pen;
productMap[Lamp.getName()] = Lamp;
productMap[Speaker.getName()] = Speaker;
return 0;
}
The WARNING messages
--------------------
c:\program files\microsoft visual studio\vc98\include\xtree(118) : warning C4786: 'std::_Tree<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,
Product>,std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Product,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<product> >::_Kfn,std::less<std::basic_string<char,std::cha
r_traits<char>,std::allocator<char> > >,std::allocator<product> >' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\map(46) : see reference to class template instantiation 'std::_Tree<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::pair<std::basic_string<char,std::char_traits<
char>,std::allocator<char> > const ,Product>,std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Product,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<product> >::_Kfn,std::
less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<product> >' being compiled
C:\C++ Practice\map\map14.cpp(50) : see reference to class template instantiation 'std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Product,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<c
har> > >,std::allocator<product> >' being compiled
|
|
|
|
|
The warning about >255 identifiers is a known problem with STL. You can safely ignore or disable that warning.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
how can you disable that?
I got a same error with this code:
#include <windows.h>
#include <conio.h>
#include <string>
#include <deque>
using namespace std;
int main()
{
deque<string> lines;
return 0;
}
|
|
|
|
|
|
I posted a message last week about this, and have made a little progress, but am stumped by what is happening now.
To review:
I have a DLL that is currently being statically loaded. I want to take this DLL and
link it to my app as a static *library*. This code uses MFC. The "interface" for
the DLL is comprised of over 100 functions. I want the code that WAS in the DLL to
be physically part of the executable (so I don't have to ship the DLL).
What I've done:
I created a new project (static library) using AppWizard. I then created a class
(with no base class) to wrap all of the old interface functions, and added the
source files from the origianl DLL to the project. This LIB file compiles just
fine (0 errors, 0 warnings).
I created a test app that links the LIB file in, but I get the following unresolved external errors:
"protected: static struct AFX_MSGMAP const CWinApp::messageMap" (?messageMap@CWinApp@@1UAFX_MSGMAP@@B)
"protected: int __thiscall CWinApp::Enable3dControlsStatic(void)" (?Enable3dControlsStatic@CWinApp@@IAEHXZ)
"protected: static struct AFX_MSGMAP const CDialog::messageMap" (?messageMap@CDialog@@1UAFX_MSGMAP@@B)
I had to ignore libcmt.lib and nafxcw.lib in the test application to get this far.
Does anyone know what I'm doing wrong? Should I forego the class approach and just expose all of the old interface functions seperately? (I honestly don't see how this could matter.)
|
|
|
|
|
John,
Check to make sure that for the static LIB project that the 'use MFC' setting is the same as is used by the application that will link with this static LIB. MFC must be either statically linked or it can either dynamically linked, but at the end of the day when linking all those .LIB's together, that setting must be the same for all compile units.
HTH.
Chris
|
|
|
|
|
Yup, that was it. I found that right after I posted this message. Thanks.
|
|
|
|
|
I need to write an app to programmatically unbind a certain protocol from a network card. E.g. Check if Netbeui is bound to a certain ethernet network card and if so then I need to unbind it (without user intervention). The idea is that after running the app only TCP/IP would be bound to the ethernet card no matter what additional protocols are installed on the computer.
I've got it working in Win2k (with the use of the INetCfg API calls) but I can't find any API calls or code examples on how to do this in Win98/Win Me and NT4.
Any ideas?
|
|
|
|
|
What I'd like to do is to cature the contents of a window that is low in the z-order / burried by other windows.
I've tried using Joseph Newcomer's www.codeproject.com/bitmap/screencapture.asp Screen Capture To Clipboard function but this seems to capture whatever is highest in the z-order / currently displayed.
Any ideas anyone please?
|
|
|
|
|
hey jeremy ... think about it ... the only thing that knows whats in a window usually is the app that created it and will re-create it on a wm_paint message ... therefore the window contents don't necessarily exist until the app is top of the z-order so capturing its contents might be tricky
i honestly can't think of a way to do what you want without the co-operation of the original app creators
i hope someone points out i'm wrong and its just as easy as calling CCopyHiddenWindowContents() or whatever
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
You'd have to get hold of the Window HWND via the FindWindow() function, and then you'll have to use SetWindowPos to set it always on top.
Then you should be able to capture the contents.
Cheers,
Peter Pearson
|
|
|
|
|
Check the WM_PRINT and WM_PRINTCLIENT messages. If you're using MFC, there's even a CWnd::Print method. MSDN says:
"The WM_PRINT message is sent to a window to request that it draw itself in the specified device context, most commonly in a printer device context."
So you should create the memory device context and send WM_PRINT to the window you want to capture, passing HDC as wParam. You'll find more info in MSDN.
Cheers,
Tomasz Sowinski
|
|
|
|
|