|
How do I retrieve the command line arguments from an MFC Dialog Based application
Stephane
|
|
|
|
|
With CWinApp::ParseCommandLine() and after with CCommandLineInfo::ParseParam for get each param.
Cheers!!!
Carlos Antollini.
|
|
|
|
|
You can also use __argv and __argc variables. These are globals maintained by MFC.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
I'm using CFileFind to search files:
CListBox* pListBox = (CListBox*)GetDlgItem(IDC_FILE_LISTING);
pListBox->ResetContent();
CFileFind finder;
CString extension = "*.scr";
CString filepath = "";
BOOL haveFile = finder.FindFile(extension);
while (haveFile)
{
haveFile = finder.FindNextFile();
pListBox->AddString((LPCTSTR)finder.GetFileTitle());
}
I want to make it to search for a directory...for example, search c:\abc\cde\*.scr, where my program.exe file is in c:\abc....how can i do that?
|
|
|
|
|
To get the directory where your program is located :
void GetLaunchedDir(CString& strLaunched)
{
TCHAR szFullPath[MAX_PATH];
TCHAR szDir[_MAX_DIR];
TCHAR szDrive[_MAX_DRIVE];
//
// get apps full path
//
::GetModuleFileName(NULL,szFullPath,MAX_PATH);
//
// break full path into separate components
_splitpath(szFullPath, szDrive, szDir, NULL, NULL);
//
// Store apps drive and path
strLaunched.Format(_T("%s%s"), szDrive, szDir);
}
Usage :
CString exePath;
GetLaunchedDir(exePath);
SetCurrentDirectory(exePath);
|
|
|
|
|
Let your function take a starting directory as a parameter (that you pass to FindFile).
Then if you are looking at a directory in your list (IsDirectory()), call your own function with the parameter of the current directory. You will then recursively go through all of your files.
A common 'add' function in your application called from your find routine will let you gather them all up.
--Mark Terrano
www.ensemblestudios.com
(Creators of the Age of Empires series)
|
|
|
|
|
Can somebody help me in showing me how to create different types of view.
I have an MDI app which in one view I would like to show a derived class from CFormView for inserting,updating purpose.
And I want to show Another view with the listings. Of course show each one in separates views.
|
|
|
|
|
Create another class derived from whatever type of view you want such as CListView, etc. Then use add a splitter window to the MainFrame class and viola. This can also be done in an SDI and would be more practical if you don't need multiple windows since the splitter window can split a single window.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Hello, I have an MFC application in which when I run one of the .dlls, I wish for the dialog box it pops up to be able to display HTML documents. I'm pretty sure I need to do this with an ActiveX control but I have no clue how to go about doing it .. could someone point me in the right direction?
|
|
|
|
|
You need to use the CHtnlView Class.
The problem is that this class is a View Class, but if you need to use it in a dialog you can see an excelente article of Paul Dilascia in the MSDN magazine or MSJ where Paul used that class in a Dialog.
Check Here http://www.microsoft.com/msj/0100/c++/c++0100.asp
Good luck!!!
Carlos Antollini.
|
|
|
|
|
Anybody knows how can I get an specific parameter of a current CPen object (color, style, or width) and how to change it?
|
|
|
|
|
You can't - you need to make a new one. Use GDI+ for a pen that allows parameter changes.
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 suppose you have a CPen object, pen.
Use pen.GetObject() to retrieve a LOGPEN structure.
Modify the parameters you need, then create another CPen to replce the old one. You may also reuse the same object: pen.DeleteObject(); pen.CreatePenIndirect().
If the pen you want to modify is selected into a CDC, use this to get a pointer to a temporary CPen:
CPen* pPen = (CPen*)dc.SelectStockObject(NULL_PEN);
Paolo.
|
|
|
|
|
Hello,
I'm having trouble using the SQLGetPrivateProfileString() method. I have an ODBC Sybase database configured as "123" in the User Data Sources section. This corresponds in the registry to:
\HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\123
I want to retrieve the string value (REG_SZ) "DatabaseSwitches" which just
contains "netbios". I called SQLGetPrivateProfileString() as follows:
int numread =
SQLGetPrivateProfileString(
"123",
"DatabaseSwitches",
sdefault,
buffer,
retbuf,
"ODBC.INI");
and it does not return anything. Any ideas what I'm doing wrong?
Thanks!
Derek
|
|
|
|
|
Try with this.
int numread =
SQLGetPrivateProfileString(
"123",
"DatabaseSwitches",
sdefault,
buffer,
sizeof(buffer),
lpzsFilename); //lpzsFilename must be LPCSTR
I saw that you try to pass the last parameter when this parameter is type Output.
What value has numread after to execute the function?
Best Regards.
Carlos Antollini.
|
|
|
|
|
I get easily confused with all of MS's macros - LPCSTR, etc. , so here's what I tried:
char *lpszFilename = new char[250];
ZeroMemory(lpszFilename, sizeof(lpszFilename));
numread = -1;
numread =
SQLGetPrivateProfileString(
"123",
"DatabaseSwitches",
sdefault,
buffer,
sizeof(buffer),
lpszFilename); //lpzsFilename must be LPCSTR???
delete [] lpszFilename;
The only thing that changed was numread=0.
|
|
|
|
|
I get easily confused with all of MS's macros - LPCSTR, etc.
Don't worry about that.
Also You need to assign memory to variable buffer because in the buffer variable you will reciebe the string.
Also you need to copy de path of ODBC.ini in lpszFilename.
strcpy(lpszFilename, "ODBC.INI");
if all is OK you the function will return the number of chars in numread and the string in buffer, if this don't work, try to copy in lpszFilename the complete path of odbc.ini.
Carlos Antollini.
|
|
|
|
|
Good news! I figured out what was happening. I was asking for a value that was not in the odbc.ini *FILE* in \winnt. I thought that SQLGetPrivateProfileString() got values from the registry based on the MSDN help:
A configuration mode indicates where the Odbc.ini entry listing DSN values is in the system information. If the DSN is a User DSN (the state variable is USERDSN_ONLY), the function writes to the Odbc.ini entry in HKEY_CURRENT_USER. If the DSN is a System DSN (SYSTEMDSN_ONLY), the function writes to the Odbc.ini entry in HKEY_LOCAL_MACHINE. If the state variable is BOTHDSN, HKEY_CURRENT_USER is tried, and if it fails, HKEY_LOCAL_MACHINE is used.
What am I missing here?!
|
|
|
|
|
Okay - I really have it working now. I'm not sure it wasn't before, but here's what I did:
CString sDsn = "123";
CString sEntry = "DatabaseSwitches";
CString sDefault = "netbios";
CString sFilename = "ODBC.INI";
char pszRetBuffer[MAX_FNAME_LEN];
ZeroMemory(pszRetBuffer, sizeof(pszRetBuffer));
numread = SQLGetPrivateProfileString(
(LPCSTR)sDsn,
(LPCSTR)sEntry,
(LPCSTR)sdefault,
pszRetBuffer,
sizeof(pszRetBuffer),
(LPCSTR)sFilename);
Thanks again for all the help!
Derek
|
|
|
|
|
I get easily confused with all of MS's macros - LPCSTR, etc. , so here's what I tried:
char *lpszFilename = new char[250];
ZeroMemory(lpszFilename, sizeof(lpszFilename));
numread = -1;
numread =
SQLGetPrivateProfileString(
"123",
"DatabaseSwitches",
sdefault,
buffer,
sizeof(buffer),
lpszFilename); //lpzsFilename must be LPCSTR???
delete [] lpszFilename;
The only thing that changed was numread=0. Can you get this to work on your system?
Thanks,
Derek
|
|
|
|
|
I guess that there must be many ways to do this, but could you guys give me any ideas, links, etc.? Also, what is the proper term for this, I've read somewhere that the expression "timebomb" is not really appreciated in the industry...
Thanks!
|
|
|
|
|
Lots of different ways, but I'd make one very serious suggestion - if you want to release a crippled version, I'd actually strip out all the code you don't want to give away. Because if you put something like this at the top of your code:
m_bFullVersion = CheckIfFullVersion();
then a cracker has one point to modify and your pants are down. Better not to distribute at all any code you want people to pay for IMHO.
I'd suggest keeping track of the date in multiple ways, so if one is tampered with, you find the details elsewhere and shut down ( your trial has expried, please go to www.payme.com to register ). If one of those ways is obvious (.ini or registry ), people trying to tamper will start there and it will all be over for them.
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.
|
|
|
|
|
Hi,
problem:
When I launch MSDN Library (separately or by pressing F1 in Visual C++) it immediately sucks down every available resource and just sits. I can see the hh.exe (MSDN) process in the task list, but it hangs. No windows pop up or anything. I think, there is a problem with the HTML Help system.
I have tried to uninstall and re-install MSDN, IE5.5 and Win2000 but it didn't help. Does anyone knows what to do?
tnks,
Phil
system:
Win2000SP2, VS6 enterpr. SP5, IE5.5SP1
|
|
|
|
|
I had this happen a few days back, thought I was using XP... I ended up reinstalling -- using Win2K Pro now, and evrithing seems fine.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Same here. One time after a crash this behavior started and my only remedy was to reinstall MSDN. After which everything worked fine (I did try recreating my project dynamic files, etc).
--Mark Terrano
www.ensemblestudios.com
(Creators of the Age of Empires series)
|
|
|
|