|
There should be some helpful information in P.J. Naughter's article here on the site:
http://www.codeproject.com/system/cntservice.asp
|
|
|
|
|
check this:
CCommandLineInfo cmdInfo;
AfxGetApp()->ParseCommandLine(cmdInfo);
if (AfxGetApp()->m_lpCmdLine[0] != '\0')
{
char tmp[1000];
sprintf(tmp,"%s",AfxGetApp()->m_lpCmdLine),
AfxMessageBox(tmp);
}
else;
In CDialog-GUI you need the CWinApp-pointer (AfxGetApp()).
|
|
|
|
|
Hi all,
I have a problem that should have a simple solution. I have an MDI FormView-based app and it has two button on the toolbar where the user can choose to create a new form-based document version 1 or version 2.
Therefore I think I have 2 issues:
one, how to set the global variable after either clicking button 1 or 2. What function should I call after setting the var?
void CMainFrame::OnFileNew2()
{
view = 2; // set the global var
... // what function should be here to continue creating new doc?
}
two, how to choose the view based on the global var.
Can anyone help me? or does anyone have a sample code that just does that?
Thanks a lot in advance.
|
|
|
|
|
peace
every poor app can open an iexplore instance and tell it where to surf to ...
is there a doc on the web about this ?- i ownly found some on how to use CWebBrowser2 to write a new one
thanx
|
|
|
|
|
You can call ShellExecute() and pass it a URL (be sure to include the "http://" part) and it'll launch your default browser.
Look around in the registry under HKCR\http to find out more about the commands issued.
|
|
|
|
|
I am trying to manage a main dialog that must appear at the beginning of the app, disappear when the user has chosen an action an then reappear when the user has finished. It's kind of a primitive approach, but the users are all used to an old DOS program that I am converting to Windows. Can I mange the whole thing in CMainFrame?
Thanks,
F.L.
|
|
|
|
|
yup..make a function that displays your dialog and call that function from OnCreate and then later from OnDestroy... =)
|
|
|
|
|
Hi !
I wanna insert a bitmap in IE menu with the command InsertMenu (SDK) by an other app.
But i've never managed in that task
Someone could help me.
Shellmind.
|
|
|
|
|
Do you know how to export the settings under a directory in registry? I can use Export in Regedit, but i dont know how to invoke export programmatically. Any ideas? Thanks all!
|
|
|
|
|
Look up the RegSaveKey() function.
|
|
|
|
|
Hello,
for a project i want to be able to read contents from the registry of a remote machine (Windows 2000).
The problem is that the connection with RegConnectRegistry works, then i am able to open a key (RegOpenKeyEx and RegCreateKeyEx) and then read from it (with RegQueryValueEx). This goes ok for 2 times with REG_SZ values but then with a third ("VendorIdentifier" or "Identifier") i get an error message 997 that states error I/O operation pending.
I tried to work with WaitForSingleObject to wait until the 'server' is ready to send but this results in a wait failed and i am a bit clueless now!
Anyhelp would be very appreciated! =)
|
|
|
|
|
Hi,
isn't there any mapping function to convert a float to a unicode string?
_ttoi() and _ttol() are defined but im am missing _ttof().
Tx, Chris
|
|
|
|
|
Try
_stprintf(string, format, float value);
|
|
|
|
|
Hi Serge,
i need the conversion from ascii to float, not the other way round.
Tx, anyway for answering.
Chris
|
|
|
|
|
Hi all!
Maybe you can help me out with a little troubling issue I have regarding visual c++ 6. I have a piece of hardware that resides on 0x000D9000 (base), and that looks at the range (base to base + 603). This is a custom made piece of hardware so there is no driver for it. The thing is, I need to write a byte value to, lets say, (base + 30). But I can't get this to work correctly.
Does anyone have an idea on how to handle this?
Kind regards,
Bas Scholtemeijer
swave333@hotmail.com
|
|
|
|
|
Check www.sybera.de (SHA).
This package should have a memory-driver.
Try this site, maybe it's helpful.
|
|
|
|
|
I am new at Visual C++ and have an assignment due in a week. Not happy. Basically I need to be able
to select some files in some way, and add them to a list box so I can ouput the paths to a text file.
If anyone can help, I would be very thankful.
Thankyou
Matt
|
|
|
|
|
Use a CFileDialog to select files, then use the GetPath function to get the path selected ( I'm not sure of the mechanics of stepping through multpiple selections ), then add then to the list box as you get them from the dialog.
LMK if you have any other problems, but that should get you started. Do you have the MSDN help ? If not, get it, it is invaluable.
|
|
|
|
|
I'm trying to add a vertical rebar to the MFCIE sample application. As a start, I'm just adding a CStatic control that reads "test." It seems to work fine when I use a horizontal control, but not vertical (using CBRS_LEFT style). The rebar doesn't paint the space below the static control (so it takes a snapshot of whatever's behind the window). I can fix that problem by calling ModifyStyle(0,CCS_VERT) after I Create() the CReBar, but now the rebar width gets confused and is set to the same value as the height. The left edge of the client area moves way to the right and there is a big unpainted 'hole' between the rebar and the client area.
I found lots of complaints about this problem on microsoft.public.vc.mfc, but no solutions. Has anyone solved this problem?
|
|
|
|
|
Given the following code:
struct SLOT
{
CString sField1;
int nField2;
};
SLOT* m_pSlots[5];
void CMyClass::InitSlots()
{
for (int i = 0; i < 5; i++)
{
m_pSlots[i] = new SLOT;
if (m_pSlots[i])
{
m_pSlots[i]->sField1 = "Empty slot";
m_pSlots[i]->nField2 = i;
}
}
}
Would you say it is morte correct to say that m_pSlots is a pointer to an array, or that m_pSlots is an array of pointers?
My view is that it's an array of pointers, but my boss insists that it's a pointer to an array.
|
|
|
|
|
Aargh... the "pointers to pointers" syndrome.
Without looking at a C++ reference book or looking at the compiler output, my money is on your boss.
But then again...?
Stroustrup will hopefully give you the correct answer...
|
|
|
|
|
Stroustrup (2nd edition) says that using "[]" is the same as saying "array of" and using "*" is the same as saying "pointer to".
I think the interpretation of the code depends on the context in which the construct is used, and how you choose to organize it in your head. When I see this:
SLOT* m_pSlots[20];
I see an array of pointers to 20 SLOT objects. This is further supported by the way the code was written to access the array:
m_pSlots[0]->sField1 = "Text";
m_pSlots[0]->nField2 = 1;
In the context I gave, I view it as an array of 20 pointers to SLOTs. I personally don't see how it could be logically interpreted any other way, but I do recognize the fact that you can call it a pointer to an array, but doing so obfuscates the paradigm given the context in which the code exists, IMHO.
|
|
|
|
|
Back at work and armed with stroustrup and the compiler, I think there is only corect viewpoint: yours.
But talking about obfuscating code. I hope for your work buddies sake you’re not using this kind of C++-isms all over your code.
Completely beside the point, of course, but what is the advantage of your piece of code over the following code (and don’t say 'memory usage' please, because I will say 'speed'...) or did you just wanted to prove your point and embarrass your boss (and me)?
struct SLOT
{
CString sField1;
int nField2;
};
SLOT* m_pSlots = NULL;
void InitSlots()
{
m_pSlots = new SLOT[5];
for (int i = 0; i < 5; i++)
{
m_pSlots[i].sField1 = "Empty slot";
m_pSlots[i].nField2 = i;
}
}
void DeleteSlots()
{
delete [] m_pSlots;
}
int main(int argc, char* argv[])
{
InitSlots();
DeleteSlots();
return 0;
}
|
|
|
|
|
I think memory usage would be close (if not identical) because we are talking about a given struct within a finite array.
As for speed, I don't know if that would matter until we were talking about thousands of elements or hundreds/thousands or new/delete pairs.
And yes, I obfuscate my code like this all the time, and no, I wasn't trying to embarass anyone.
|
|
|
|
|
> I think memory usage would be close (if not identical) because we are talking about a given struct within a finite array.
~ Correct.
> As for speed, I don't know if that would matter until we were talking about thousands of elements or hundreds/thousands or new/delete pairs.
Actually, calling X times an allocation/de-allocation routine is almost ~X times slower than calling it once with a X-time larger memory chunk (provided it doesn't trash the OS). cfr. a good OS internals book, e.g. http://www.sysinternals.com/insidew2k.htm
> And yes, I obfuscate my code like this all the time, and no, I wasn't trying to embarass anyone.
Phew, thanks.
Since we are on a roll here: Do you want to stick your neck out? Try this one:
Write down the output of the listed program without compiling and running it. Then check the results...
But then again, of course, you do this in a jiffy.
class foo
{
public:
foo() {}
virtual ~foo() {}
virtual void Print(void)
{
cerr << "it's foo!\n";
}
void Print(int err)
{
cerr << "it's foo with err : " << err << "\n";
}
};
class childfoo1 : public foo
{
public:
childfoo1() {}
~childfoo1() {}
void Print(void)
{
cerr << "it's childfoo1!\n";
}
void Print(int err)
{
cerr << "it's childfoo1 with err : " << err << "\n";
}
};
class childfoo2 : public foo
{
public:
childfoo2() {}
~childfoo2() {}
void Print(void)
{
cerr << "it's childfoo2!\n";
}
void Print(int err)
{
cerr << "it's childfoo2 with err : " << err << "\n";
}
};
// which Print function is called ??
int main(void)
{
foo * foopointer1 = new childfoo1();
foo * foopointer2 = new childfoo2();
foo * foopointer3 = (childfoo1*) foopointer2;
childfoo1 * foopointer4 = (childfoo1*) foopointer2;
cerr << "\n1 ";
foopointer1->Print();
cerr << "\n2 ";
foopointer2->Print();
cerr << "\n3 ";
foopointer3->Print();
cerr << "\n4 ";
foopointer4->Print();
cerr << "\n5 ";
foopointer1->Print(5);
cerr << "\n6 ";
foopointer2->Print(5);
cerr << "\n7 ";
foopointer3->Print(5);
cerr << "\n8 ";
foopointer4->Print(5);
delete foopointer1;
delete foopointer2;
return 0;
}
|
|
|
|