|
Just an inquiry...
How do I implement my program so that if I made it an executable file, it's possible to pass "arguments/parameters" to the executable file when it is called...
i.e.
if I made my BOOk Program as an executable file
and I want my executable file of the Book program to accept video file parameters, how do I do this?
In analogy, if i want to open the realplayer.Exe, i command a SHELLEXECUTE with the *.rm file as paramenter and the realplayer automatically opens it.
Thanks in Advance. Best Wishes to all.
|
|
|
|
|
pass the parameters on the command line:
c:\> MyApp.EXE file.ext
in your app, use one of the many command line parsers available here to grab the parameters and act accordingly.
-c
Smaller Animals Software, Inc.
|
|
|
|
|
Sorry, u might have misunderstood my question 'cuz it seems a little bit confusing...
to clarify: I'll set an example.
I have two programs: "X" and "Y" program.
-I programmed X to process video files. then convert it to executable file
-I have another program Y which calls this executable file of X (X.exe) with a VIDEO FILE parameter possibly using the command
ShellExecute (hwnd, "open", "X.exe", [Video File PathName], [Directory of Executable File], SW_SHOWNORMAL);
so the question is, how do i Program X so that it can accept the VIDEO FILE parameter of Y. and open it afterwards.
Y ---video file ---> X.exe
Thanks in Advance...
|
|
|
|
|
The command line parameters can be used in the InitInstance() of
your application. The command line is stored in m_lpCmdLine which is
a char array. If you pass your parameter with a slash (ie. /MYPARM)
they will be considered flags. If you don't include the slash the first
parameter will be considered to be the file you want to open. You can
turn off that behavior my setting:
cmdIndo.mShellCommand = CCommandLineInfo::FileNew;
but why not just include the slash?
*NOTE you can test your command line parameter in the developer studio!
see the PROJECT - SETTINGS - DEBUG(tab)
I usually deal with the command line in my applications InitInstance() just before:
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
|
|
|
|
|
Thanks a lot .. I'll try to implement your suggestion.
|
|
|
|
|
Hi,
Does anyone know how to go about programatically enumerating the network server dns name etc, on a mapped dive under NT?
Say I have a drive H:\ I can see that the server path is 'trtdatasrv\data' in Explorer.
I have a database for cataloging files, but need to know if the user is pointing to the same H drive as well as others, and if not map to it.
Thanks,
Giles
|
|
|
|
|
Hi Giles:
You need to use the Distributed File System (Dfs) Functions....
Start with NetDfsEnum and you will can find other functions that will can help you... ;););););););)
Best Regrards....
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Hi Folks!
I'm trying to print a CDialog to a printer CDC. Without any scale conversion, it's way to small. So I use the CWnd::Print function to draw to a bitmap, and StretchBlt() it onto the printerDC. It works, but the resolution of the text is horrible. How can I get a CDialog to print at a higher resolution?
If it's not too stupid a question, I'd be grateful for some help.
Jonnie
|
|
|
|
|
Printer page has more pixels than dialog, I guess your problem is not resolution but pixelization. Try to make smooth magnification using SetStretchBltMode.
|
|
|
|
|
Thanks. Doesn't seem to be the solution though. Isn't it possible to pass the CDialog a device context with a higher resolution, and get it to draw it (avoiding the rasterization which occurs when stretching)?
Jonnie
|
|
|
|
|
I'm having problems using qsort on a CArray of pointers. I've read the CP article 'Using qsort on arrays of sequential data' but this doesn't sort pointers - it only mentions having to do a second level of casting when sorting pointers.
Here's a simplified version of what I'm doing:
header file
===========
// data to be sorted
class CFundData
{
public:
CFundData() {}
virtual ~CFundData() {}
CString m_sFundId;
CString m_sFundName;
};
// array of CFundData*
typedef CArray<CFundData*, CFundData*> CFundDataPtrArray;
// sorting functions
typedef int (*QSORT_FUNC_T)(const void*, const void*);
void SortFundData(CFundDataPtrArray& arrayFundData);
int __cdecl CompareFundData(const void* elem1, const void* elem2);
implementation file
===================
void Foo()
{
// array of CFundData*
CFundDataPtrArray arrayFundData;
// populate array with data
CFundData* pFD = NULL;
pFD = new CFundData; pFD->m_sFundId = "S100"; pFD->m_sFundName = "GHI";
arrayFundData.Add(pFD);
pFD = new CFundData; pFD->m_sFundId = "S200"; pFD->m_sFundName = "ABC";
arrayFundData.Add(pFD);
pFD = new CFundData; pFD->m_sFundId = "S300"; pFD->m_sFundName = "DEF";
arrayFundData.Add(pFD);
// sort the array
SortFundData(arrayFundData);
}
void SortFundData(CFundDataPtrArray& arrayFundData)
{
// sort array using qsort and the comparison
// function CompareFundData
if (arrayFundData.GetSize() > 0)
{
qsort((void*)arrayFundData[0], (size_t)arrayFundData.GetSize(),
sizeof(CFundData*), (QSORT_FUNC_T)CompareFundData);
}
}
int CompareFundData(const void* elem1, const void* elem2)
{
// comparision function to sort by FundName
CFundData* pFD1 = (CFundData*)elem1; // 'bad' first time called
CFundData* pFD2 = (CFundData*)elem2; // 'good' first time called
return pFD1->m_sFundName.Compare(pFD2->m_sFundName);
}
The first time CompareFundData is called pFD2 is ok (it's the first item in the array) but although pFD1 'looks' like the second item in the array, it is not a valid CFundData object.
I know I should probably be using the STL, but I don't want to bring it into the app for this 'simple' sort. Can anyone help?
Gavin
|
|
|
|
|
I would recommend using STL and a vector template.
May sound a pain, but is much easier than it seems and gets around loads of problems with CArray.
e.g.
#include <vector>
using namespace std;
vector<CFundData> vCFundData;
CFundData a, b, c;
vCFundData.push_back(b);
vCFundData.push_back(a);
vCFundData.push_back(c);
sort(vCFundData);
Also see STL Sort Article
Hope this helps.
Giles
|
|
|
|
|
I know I should probably be using the STL, but I don't want to bring it into the app for this 'simple' sort.
You really should, there's nothing wrong with bringing STL to an app however small that app is. Note also that STL sort algorithm will work with your CFundDataPtrArray s, no need to switch to std::vector s.
Anyway, your problem with how you're using qsort is that you need an extra layer of indirection. Do not pass pointers to qsort , pass it pointers to pointers. Here's how:
void SortFundData(CFundDataPtrArray& arrayFundData)
{
if (arrayFundData.GetSize() > 0)
{
qsort((void*)&arrayFundData[0],
(size_t)arrayFundData.GetSize(), sizeof(CFundData**),
(QSORT_FUNC_T)CompareFundData);
}
}
int CompareFundData(const void* elem1, const void* elem2)
{
CFundData** pFD1 = (CFundData**)elem1;
CFundData** pFD2 = (CFundData**)elem2;
return (*pFD1)->m_sFundName.Compare((*pFD2)->m_sFundName);
} Again, this would be greatly simplified by using STL sort , which is a generic soultion that will pay off in the long term.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your reply - the qsort now works a treat!
I've had a go at using the STL sort and vector:
// declare vector
vector<cfunddata*> vFD;
vector<cfunddata*>::iterator it;
// populate vector
...
// sort the vector
sort(vFD.begin(), vFD.end(), compareFundName);
// comparision function
bool compareFundName(const CFundData* lhs, const CFundData* rhs)
{
return lhs->m_sFundName < rhs->m_sFundName;
}
This works, and is definately neater than the qsort approach. Is this the best STL way? You mentioned using STL sort with CFundDataPtrArray, but I'm not sure how to do this.
Gavin
|
|
|
|
|
This works, and is definately neater than the qsort approach. Is this the best STL way? You mentioned using STL sort with CFundDataPtrArray, but I'm not sure how to do this.
This should do:
std::sort(
&arrayFundData[0],
(&arrayFundData[0])+arrayFundData.GetSize(),
compareFundName);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Wow! That's very nice - I'll take it. Thanks for your help.
Gavin
|
|
|
|
|
Hi,
I cant find classwizard to handle messages as WM_CREATE ...
Where is it ??
|
|
|
|
|
The short answer is: it's gone.
The class wizard in VS .NET is replaced by the property grid. Simply open the cpp file of your class and then click on the property tab. You will see the events and messages in the grid.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Thankx
And handle messages WM_CREATE for control as button, static ??
...in the resource editor is the page "messages" disable for control ((
Wiizi
|
|
|
|
|
If you want to add handlers for dialog controls, you need to bring the dialog in the resource editor and then you should see the messages in the property grid.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Is not ClassWizzard in .NET
But if you are experimented programmer in VC++, don't need the Classwizzard ;););)
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
?? I dont like writing too much code therefore i use (my fried)classwizard
Wiizi
|
|
|
|
|
How to add a menu item to the sysmenu in hWnd with sysmenu ID ID_SYSMENU?
The hWnd is another app that I've done, and my other app is to make it possible to add a menu item to my other app.
Can you illustrate a code for me!! I've been doing it for a while but can't get it to work...
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
How do i send a file over a tcp connection with a normal CSocket? or whats the easiest way to do this??
Kuniva
--------------------------------------------
God gave man a penis and a brain but not enough blood to make both of 'em work at the same time.
|
|
|
|
|
Hi Kuniva,
After you called the create and connect functions on the sockClient_ (client socket), do this
...
CSocketFile file_(&sockClient_);
CArchive outFile_(&file_,
CArchive::store);
outFile_ << xpto; // the data you want to send
note : this only works for stream connection
On server side you do the opposite :
... // do the accept and listen and ...
CSocketFile file_(&sockServer_);
CArchive inFile_(&file_,
CArchive::load);
inFile_ >> xpto;
for more examples, you could check the CHATSRVR and CHATTER on MSDN
or the site for good examples of socket programming http://www.sockets.com/
Cheers,
Joao Vaz
|
|
|
|