|
I personally found that messing around with a few example applications from here at the Code Project (from various authors) was the best way to pick things up, really. Like you, I was doing mostly console-type apps and tons kernel mode dev., leaving my MFC and UI coding skills a little thin (actually, they were non-existent!).
Also, if you use the built-in Wizard to create an MFC app, you can get it to create a simple app for you right off the get-go that even compiles - start mucking around with the created project - I recommend starting out with a bare-bones Dialog app persobally, CDialog is a lot quicker to pick up and learn how to plop down controls and muck around with them.
Have fun with the learning, I've been messing with MFC now since Aug 2001 and have personally found that the examples here are fantastic learning tools for people who learn by example.
: Dean 'Karnatos' Michaud
|
|
|
|
|
Thank you,That is exactly what I need
Vitaliy
|
|
|
|
|
SystemParametersInfo(SPI_SETSNAPTODEFBUTTON, true, NULL, SPIF_UPDATEINIFILE | SPIF_SENDCHANG)
Above is my code.
It works in WinMe, Win2000 and WinXP
but does not work in Win98.
Is anyone can give me any suggestion?
Thanks a lot.
|
|
|
|
|
Hello,
I'm trying to use GetModuleBaseName and EnumProcessModules, but I'm doing something wrong because I get linker error 2001. I guess that the problem is with WINAPI.
I have a .c file that is forced to be compiled as c++ and I call those functions from there like this:
EnumProcessModules(hProc, &hMod, sizeof(hMod), &cbNeeded);
GetModuleBaseName(hProc, hMod, pParentName, sizeof(pParentName));
Then I'm using PSAPI.h where I have
-- clip --
#ifdef __cplusplus
extern "C" {
#endif
-- clip --
BOOL
WINAPI
EnumProcesses(
DWORD * lpidProcess,
DWORD cb,
DWORD * cbNeeded
);
-- clip --
DWORD
WINAPI
GetModuleBaseNameA(
HANDLE hProcess,
HMODULE hModule,
LPSTR lpBaseName,
DWORD nSize
);
DWORD
WINAPI
GetModuleBaseNameW(
HANDLE hProcess,
HMODULE hModule,
LPWSTR lpBaseName,
DWORD nSize
);
#ifdef UNICODE
#define GetModuleBaseName GetModuleBaseNameW
#else
#define GetModuleBaseName GetModuleBaseNameA
#endif // !UNICODE
-- clip --
#ifdef __cplusplus
}
#endif
-- clip --
Now I get:
myprogram.obj : error LNK2001: unresolved external symbol _GetModuleBaseNameA@16
myprogram.obj : error LNK2001: unresolved external symbol _EnumProcessModules@16
Why?
I've read many examples and it seems to me that I'm doing this in the same way as they do.
I would be glad if someone helped me with this.
-Janetta
|
|
|
|
|
Ok, it is a linker error !
Come on, its the most common of the
linker errors !.
You forgot to include the psapi.lib
in your linker tab.
|
|
|
|
|
It is very common, but there are many reasons why you get it. Maybe this mistake was trivial, but it was new to me. Thank you anyway
-Janetta
|
|
|
|
|
Hi all,
I'm working with a database application in which the data base is located in a remote machine(Machine 1).The application which makes use of that data base is running on a remote machine(Machine 2).Both computers are running under Windows 2000 and are connected in LAN.I would like to clear my database(The database located in machine 1) once in a month by running an exe in that machine.How can i invoke another executable program(program for backing up the data base) which is located in machine 2 when the data base clearing program in machine 1 is just started.Can any one help me?.
With regards.
Shibu K.V.
Senior Research Associate.
VLSI ASIC Hardware Design Group
Electronics R&D Centre,Trivandrum
India
|
|
|
|
|
There is no existing infrastructure in place currently
to invoke a program at the remote machine.
Wait there is one way, Use the Task Schedular API.
But make sure that the remote exe is scheduled to
a future time and that it does not have a UI.
Or you could always use a Service and keep
listening on a specified port.
|
|
|
|
|
Most database applications have ablility to schedule tasks and jobs, so why write an application to do it?
|
|
|
|
|
use the Sheduletask API
or write a service
Renjith-CPian.
|
|
|
|
|
Ok, this is a revisit to the problem that Chris Losinger tried to help me with. I had wrongly thought GetFileSize was the problem, he helped me determine that was not the case, thanks again Chris!!
I have an app associated with a certain file type. When I double click the file, it opens up my app. In this way the file name is passed to the app. This works fine and I have proved it by popping a message box with the filename on it. As you can see below m_EncryptedFilePath is the file name in question.
HANDLE hOriginal = ::CreateFile(m_EncryptedFilePath,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
Now, in DEBUG mode, all is dandy. hOriginal is not NULL . But in RELEASE mode, it is NULL even though the correct file name is passed through in each case.
Could it be file permissions?? Access rights?? The way I'm associating the file with the app??
By the way, release mode works fine if I hard code the file name like so
HANDLE hOriginal = ::CreateFile("c:\\myfile.abc",
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
So I'm completely at my wits end over this at the moment. Any and all comments will be appreciated.
Senwe
And when God, who created the entire universe with all of its glories, decides to deliver a message to humanity, He WILL NOT use, as His messenger, a person on cable TV with a bad hairstyle.
|
|
|
|
|
What does GetLastError() return?
|
|
|
|
|
Good question, in DEBUG mode it returns 0, implying all is well. That's why when I'm debugging everything works. The release version of CreateFile returns a NULL handle.
Perhaps I should place a FormatMessage and populate a MessageBox to retrieve GetLastError in my release mode?
And when God, who created the entire universe with all of its glories, decides to deliver a message to humanity, He WILL NOT use, as His messenger, a person on cable TV with a bad hairstyle.
|
|
|
|
|
If you think, that to populate a MessageBox is the right answer, you have to do it. (If you know what I mean)
I also have these type of problems and I have to fix them. The first step is to get a "handle" to the problem.
You have there a member variable for the file name. I guess it is a CString -> (LPCSTR) cast is best practise.
Try also Release Output of it to check its ok. ( I Do a Findfile to check this).
|
|
|
|
|
KarstenK wrote:
The first step is to get a "handle" to the problem.
Yep and my assumption was correct, the file isn't being recognised. GetLastError confirms this.
KarstenK wrote:
I guess it is a CString -> (LPCSTR) cast is best practise
Well yes, a WTL CString, not an MFC CString
And when God, who created the entire universe with all of its glories, decides to deliver a message to humanity, He WILL NOT use, as His messenger, a person on cable TV with a bad hairstyle.
|
|
|
|
|
GetLastError returns the following...
The filename, directoryname, or volume label syntax is incorrect
Which is what I assumed...but I just don't see how or why.
And when God, who created the entire universe with all of its glories, decides to deliver a message to humanity, He WILL NOT use, as His messenger, a person on cable TV with a bad hairstyle.
|
|
|
|
|
Hi,
Sounds like a memory allocation\deallocation problem with 'm_EncryptedFilePath' especially if the path is correct('\\' etc) and it works when you hard code the path.
What type of string is 'm_EncryptedFilePath'?
|
|
|
|
|
Hi Ollie, it's a WTL CString. I've always used it as a drop in replacement for MFC's CString in most cases.
And when God, who created the entire universe with all of its glories, decides to deliver a message to humanity, He WILL NOT use, as His messenger, a person on cable TV with a bad hairstyle.
|
|
|
|
|
have you tried making a local copy of the string and then using it, sorry not up to speed on WTL CString, what is the underlying type?
|
|
|
|
|
No prob Ollie, it's a great library as you already know I'm sure, please do explore it for your new win32 work
The underlying type is LPTSTR. I think you're onto something though. Let me explore the CString header file more carefully.
And when God, who created the entire universe with all of its glories, decides to deliver a message to humanity, He WILL NOT use, as His messenger, a person on cable TV with a bad hairstyle.
|
|
|
|
|
Hello,
I'm trying to draw on a dialog but I'm having no luck with the following code. It's my first time doing any gdi/device context stuff. I know there's better ways to display info than writing directly to a dialog but it's a bit of a hack. If anybody can help, thank-you.
John
//in oninitdialog
CPaintDC dc(this); // device context for painting
CPen* oldPen;
CPen pen(PS_SOLID, 1, RGB(0,0,0));
oldPen = dc.SelectObject(&pen);
dc.TextOut(20,20,"Mean Flow Velocity (m/s)");
dc.SelectObject(oldPen);
|
|
|
|
|
Hi,
You r not supposed to use the drawing code in
OnInitDialog and more over CPaintDC should
be used only when processing the WM_PAINT msg
i.e only in OnPaint.(How abt brushing up a bit
on the documentation ?)
So move you code to OnPaint.
|
|
|
|
|
Thanks Prem
It works now.
I'm using the following in OnPaint...
CFont* pFont;
CFont* pOrigFont;
pFont= GetFont();
pOrigFont = pdc->SelectObject(pFont);
pdc->SetBkColor(GetSysColor(COLOR_BTNFACE));
pdc->TextOut(40,40,"Mean Flow Velocity (m/s)");
|
|
|
|
|
hi to all,
do u know how to get message of "copy" from rt click of a mouse.
for getting mouse message we use getkeystate..
|
|
|
|
|
hi all.
i have to Read the data for a Particular Portion of a wave file, as an Integer array or a Byte array.
how i can i use the mmioRead function for above.
Please help me very urgent
thanks in advance.
|
|
|
|
|