|
Thankx for all the response...but those two suggestions will not work..
I try import the file_1.exe as a resource file into file_2.exe Visual C++ project. I can still compile but it will not package file_1.exe into file_2.exe. There is still a requirements for copying both file_1.exe and file_2.exe to the same dir.
The link is very helpful but not in this case. It still requires two files to manage which is what I try to avoid.
|
|
|
|
|
What you want cannot be achieved. In order for file_1.exe to be "ran", it must be saved to disk first. Managing two files instead of one is hardly a showstopper, though.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
yeah Davidcrow, this definely is not a showstopper. It is just a matter of convenience.
I just found an article from this site that give me a place to start. The article is "Launching Program from Resources" by Mohammad Salah on Mar 28, 2001. It is similar to what Kuphryn had suggested earlier. This article has instruction to add exe to project resource as well as sample code to access exe from resource file. It is definitely good place to start.
Hope this will help others as well.
|
|
|
|
|
iluvyuri wrote:
This article has instruction to add exe to project resource as well as sample code to access exe from resource file. It is definitely good place to start.
I like my article better! At a minimum, it provides more detail.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I'm looking to make a dialog based program that utilizes a tab control and I'm looking for the best way to go about this. Currently I have the main dialog with the tab control on it and I've created two child dialogs to add to the tab pages. This is how I add the pages, and switch between them in my code. To me it doesn't look like the best way to do things so I was hoping to get some ideas on a better way to go about this. Here is the code:
BOOL CDataManDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_tabData.InsertItem (0, " Media Sales ");
m_tabData.InsertItem (1, " Price Information ");
VERIFY (m_dlgSales.Create (IDD_MEDIASALES_DIALOG, this));
VERIFY (m_dlgPrice.Create (IDD_PRICE_DIALOG, this));
CRect rectCtrl;
GetDlgItem (FRAME_TAB_DIALOG)->GetWindowRect (&rectCtrl);
ScreenToClient (&rectCtrl);
m_dlgSales.MoveWindow (&rectCtrl, TRUE);
m_dlgSales.BringWindowToTop ();
m_dlgSales.ShowWindow (SW_SHOW);
m_dlgSales.SetFocus ();
return FALSE;
}
void CDataManDlg::OnTabSelected(NMHDR* pNMHDR, LRESULT* pResult)
{
int nCurrentTab = m_tabData.GetCurSel ();
m_dlgSales.ShowWindow (SW_HIDE);
m_dlgPrice.ShowWindow (SW_HIDE);
CWnd* pWndCurrentTab = NULL;
switch (nCurrentTab) {
case 0:
pWndCurrentTab = &m_dlgSales;
break;
case 1:
pWndCurrentTab = &m_dlgPrice;
break;
default:
ASSERT (FALSE);
break;
}
if (pWndCurrentTab != NULL) {
CRect rectCtrl;
GetDlgItem (FRAME_TAB_DIALOG)->GetWindowRect (&rectCtrl);
ScreenToClient (&rectCtrl);
pWndCurrentTab->MoveWindow (&rectCtrl, TRUE);
pWndCurrentTab->ShowWindow (SW_SHOW);
pWndCurrentTab->Invalidate ();
pWndCurrentTab->UpdateWindow ();
pWndCurrentTab->BringWindowToTop ();
pWndCurrentTab->SetFocus ();
}
*pResult = 0;
} One thing that really bothers me is I have to have a staic control on the form that is sized to the tab control - minus the tabs (FRAME_TAB_DIALOG) in order to have the child dialogs sized correctly. This doesn't seem like a good way to do things. Any help and/or ideas would be greatly appreciated. Thanks.
- monrobot13
|
|
|
|
|
Yesterday, was a question like that, but a guy had a lot of control and he couldn't manage all of them...
I said him the better is using CPropertieSheet class with CPropertiePage....
Regards
Carlos Antollini
Do you know piFive[^] ?
|
|
|
|
|
That's an idea. Thanks.
- monrobot13
|
|
|
|
|
Can someone give me a quick explanation on copy constructors and what they are used for? I am alittel confused about them.
Thanks!!
|
|
|
|
|
The copy constructor is called instatements like this:
CFoo a;
CFoo b(a);
There are many such occasions, some more hidden (e.g. passing a CFoo as argument or return value of a function)
if you don't provide your own, C++ generates a default copy constructor, which does a "memberwise copy", i.e. the copy constructor is called for each member. "Simple" types (non-classes/structs) are copied bitwise.
Flirt harder, I'm a coder.
mlog || Agile Programming | doxygen
|
|
|
|
|
Is it a good idea to always put a copy constructor in your class? Even if you are not gonna do a copy like:
CFoo a;
CFoo b(a);
|
|
|
|
|
yes+no
When designing the class, which behavior the class should expose on copy. So you might need:
a) the default copy constructor (i.e. add don't add your own)
b) your own copy-constructor, if the default one makes something wrong/unwanted
c) a protected or private "do-nothing" copy constructor, if th class isn't copyable
Flirt harder, I'm a coder.
mlog || Agile Programming | doxygen
|
|
|
|
|
"Always" is such a strong word. As the previous reply said, if you don't define one, one is created for you. It's important for you to define one if the default behavior won't work for you. The perfect example of this is if your class includes a pointer to an object on the heap:
class CFoo {
...
CBar* m_pBar;
};
The default copy constructor will just copy the pointer, so you'll end up with two CFoo objects pointing to the same CBar object on the heap. This can result in ugly crashes if the destructor includes deleting the CBar object. So, in this case you will want to define your own copy constructor that will make a copy of the CBar object.
There's one more theory on all this. If you have a really large class with a lot of member variables and items on the heap you won't necessarily want the user of your class to be able to copy it as this will lead to poor performance. So, instead in the private section of your class declaration, declare your Copy constructor but never define it:
CFoo {
...
CFoo(const CFoo&);
};
Thus, anytime you or another future programmer accidentally calls the copy constructor on your huge class the compiler will disallow it. So, the short answer, no it's not always a good idea.
|
|
|
|
|
A copy ctor is used to instantiate an object of a class with a copy of another object of that same class. i.e. If I wanted a CPoint that had the same values as another CPoint (say, one I wouldn't want to modify), then I would do the following:
foo(const CPoint& pt)
{
CPoint MyPoint(pt);
...
}
Thus you need to implement a ctor with the following prototype:
CMyClass(const CMyClass&)
And then set all the necessary class internals needed to represent a copy.
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Hi ,
I have to implement a mode function using C++ or C .
mode is the sample occuring most num of times
eg 10 samples
1 1 1 1 1 1 1 2 2 2
the mode is 1
I wanted to know if there is any library func i can use to achieve this ?
If not I would need hints for calculating it .
I mean do I need to have an array of a struct like
typedef struct {<br />
int num ;<br />
int occurence;<br />
}MODE_STRUCT ;
and then creat a variable
MODE_STRUCT values[NUM_SAMPLES] then load the samples and find the struct having occurence as highest ?
can it be done dynamically without having an array implementation?
Finally what do i pick if the data is bi-modal or multi-modal ?
|
|
|
|
|
One solution would be to sort the numbers in the set. Set a MaxOcc counter to 0, and a Occ counter to 0. Then iterate through the set incrementing the Occ counter each time a same number is encountered. When the next number is different, if the Occ counter is greater than the MaxOcc counter, set the MaxOcc counter to Occ counter, and reset Occ counter back to 0. Something like:
sort the numbers in the set
set MaxOcc = 0 ' the maximum value of Occ
set Occ = 1 ' the number of times this number has occurred
set LastNum = Num = first number in set
for each number in set
if Num != LastNum
if Occ > MaxOcc
set MaxOcc = Occ
end
set Occ = 1
else
increment Occ
endif
set Num = next number in set
next
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Thank you David. that really helped .
|
|
|
|
|
I've got an MFC aplication (VS6, SP 5) that reads and writes text files using CFile. The applcation was installed on an NT 4.0 box. That box was recently uppgraded to Win2k server. Now a process that use to take a few minutes now takes a few hours!
Are there any "gotchas" I should be aware of when migrating a NT app to Win2k?
TIA
|
|
|
|
|
Some of the way in which the lower level IO is handled for drives, especially SCSI drives, was changed in Windows 2000 Server and later.
Maybe your NT app did something REALLY inefficient like reading 1 byte at a time from the text file off the drive instead of reading a larger block of data into memory and then parsing through that one byte at a time.
If you can control the opening flags for CreateFile, then you can investigate if FILE_FLAG_SEQUENTIAL_SCAN was used as one of the file bufering flags.
In general, I have tailored the CreateFile calls to the activity expected to be performed on each file that is opened, and have not noticed any problems like yours in switching from one system to another.
|
|
|
|
|
Hi All!
I have subclass an edit control and all works fine.
The problem is when the compiling ends I have two warnings:
warning C4312: 'type cast' : conversion from 'LONG' to 'WNDPROC' of greater size.
warning C4311: 'type cast' : pointer truncation from 'LRESULT (__stdcall *)(HWND,UINT,WPARAM,LPARAM)' to 'LONG'.
These warnings are from this code:
OldEditControl = (WNDPROC)SetWindowLong(GetDlgItem(hwnd, IDC_NUM), GWL_WNDPROC, (LONG)EditProc);
The strange is that on Win98 I don't have these warnings.
I have them on WinXP
What's wrong?
|
|
|
|
|
I am using MSVC++ 6.0 and MFC. I need to send message between two applications. I've registered a message via RegisterWindowMessage using the same string in two separate applications. The message has been sent with ::SendMessage(HWND_BROADCAST . . . and BroadcastSystemMessage, but the secnod application is not seeing the message. I can see that the message was sent by watching with Spy++.
I have attempted to watch for the message both through the messaging macro ON_REGISTERED_MESSAGE and by overriding the PreTranslateMessage method on both my view and application classes in the intended recipient.
Can anyone see what I'm doing wrong?
|
|
|
|
|
HWND_BROADCAST broadcasts messages to toplevel windows only, where are you trying to handle the message?
MFC doesn't route non command messages, so if you have a MFC app you will have to catch it in the frame window and not in the doc/view/app etc, then manually route it to the doc/view/app if you wan't to process the message there.
|
|
|
|
|
Thanks. I'll give that a try.
|
|
|
|
|
Is there a reason why the maximum buffer size for a TCHAR seems to be 121 WideChars (for me at least)? Is there a way to increase this size?
Cheers.
|
|
|
|
|
How are you allocating your buffer?
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
I'm declaring this:
_TCHAR temp[4000];
and then using it in a call to this:
int len2 = (int)strlen((char*)testLine)+1;
MultiByteToWideChar(
CP_UTF8,
0,
(char*)testLine,
len2,
(_TCHAR*)temp,
4000);
I've also tried to concat TCHAR onto TCHAR using pointers, but again it stops working when it reaches a size of 121 WideChars.
Thanks for your time,
Tom.
|
|
|
|