|
|
|
Hi I'm looking for an explanation of the REINSTALLMODE_PACKAGE flag of MsiReinstallProduct. MSDN says you can use it to reinstall from another package, for instance to update an installed product. Does anybody know how to set the new source package?
|
|
|
|
|
I tried using memcpy to copy values from an array of unsigned char to another array of the same type.
But when tried to see it using cout , nothing is displayed.
This what I did.
#include "iostream.h"
#include"memory.h"
typedef unsigned char BYTE;
void main()
{
BYTE a[3]="\xff\x00";
//BYTE *p;
BYTE s[10],r[10],q[10];
memcpy (s,a, 3);
cout<
|
|
|
|
|
What are you expecting to be displayed? The first cout statement will print the 0xff character but you'll not be able to see it as it's whitespace. The other two cout statements should print nothing.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
#include "iostream.h"
#include"memory.h"
typedef unsigned char BYTE;
void main()
{
BYTE a[3]="\x42\x41";
cout<
|
|
|
|
|
I am trying to use PC-Lint with an MFC app and am getting way too many messages where it is searching for some keywords. I would like to know if someone has got a quick start to this .
I added some additional options for a template from Scott Myers . I advised me to make some function parameters const . additionally , most of my functions do not modify data , so should i make them const ? What is the advantage of making a function const ? Apart from the fact that no one could use the function to modify existing data !
|
|
|
|
|
I stopped using PC-Lint about six months ago when it flagged perfectly good code and ignore a glaring errors, sometimes in the same file. It's a shame; it used to be a good program.
Incidentally, making a paramater or function const is an additional error check. It also reminds the developer that the class or parameter won't change; if it did, in some cases you would have to double buffer and item or ensure a string had sufficent memory allocated to it, etc.
The compiler can also use const to do some optimizations.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I have a edit box which when I set the focus will allow the user to enter text. But when the
Enter or Return key is pressed the program terminates.
I have set the property to Want Return.
I am using the event OnEnChangeEdit1 to move the text and clear down the edit box when
the data entry cycle is complete.
How do you stop the Enter/Return key terminating the program?
|
|
|
|
|
Hi,
Sounds like you have a dialog with the OK button as BS_DEFPUSHBUTTON style.
You can use the PreTranslateMessage virtual function to do whatever it is you want to do, e.g.
BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
BOOL bEatMsg = FALSE;
if (pMsg && pMsg->message == WM_KEYDOWN)
{
if (pMsg->hwnd == m_ctrlEditBox.GetSafeHwnd())
{
switch (pMsg->wParam)
{
case 13:
bEatMsg = TRUE;
break;
}
}
}
return bEatMsg?TRUE:CDialog::PreTranslateMessage(pMsg);
}
Hope this helps,
Andy
|
|
|
|
|
Thanks Andy that worked a treat.
|
|
|
|
|
sweep123 wrote:
I have a edit box which when I set the focus will allow the user to enter text. But when the
Enter or Return key is pressed the program terminates.
I have set the property to Want Return.
Is the ES_MULTILINE style also being used?
sweep123 wrote:
How do you stop the Enter/Return key terminating the program?
Read here.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
The Multi-line was set to false.
If set that to true would that have sorted out the problem?
|
|
|
|
|
sweep123 wrote:
If set that to true would that have sorted out the problem?
That's ultimately up to you to determine. All I can do is suggest what the docs indicate, namely that when a multiline edit control is in a dialog box, the default response to pressing the ENTER key is to activate the default button. To use the ENTER key as a carriage return, use the ES_WANTRETURN style.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks for the info.
One effect I have with the use of the Edit Box is that if the user presses the Tab key when the Edit Box has focus then that is taken as an Enter key press.
This is with the Tabstop set to both true or false.
Note I set the Edit Box to read only until data input is expected, then its set to false and back again to true following the data entry.
|
|
|
|
|
sweep123 wrote:
One effect I have with the use of the Edit Box is that if the user presses the Tab key when the Edit Box has focus then that is taken as an Enter key press.
This is with the Tabstop set to both true or false.
This is not normal (i.e., default) behavior, unless you are doing something special with the VK_TAB key.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi geeks,
Please tell me when to use a MACRO and when to use an INLINE FUNCTION in C++. If this question has been asked before, please point me to that link.
I need an answer comparing the two. Please dont post definitions of macro and inline function as i am aware of them. Please give the answer in terms of efficiency, speed, code-size, pre-compilation/post-compilation, and things like that.
And please give examples ...
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
always use inline ( or ordinary methods ).
the only reason I can give is that macros are preprocessor stuff and are not "debuggable"
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote:
the only reason I can give is that macros ... are not "debuggable"
That should be reason enough. Very few things should exist as a preprocessor macro. The ability to type-check parameters is a must.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
My general rule is that if it can be done as an inline function, it should be.
There are some things which cannot be done with an inline function, but can be done with a macro. Those are rare, though.
|
|
|
|
|
avenger_sb25 wrote:
Hi geeks,
That's a wee bit rude, don't you think?
avenger_sb25 wrote:
I need an answer comparing the two. Please dont post definitions of macro and inline function as i am aware of them. Please give the answer in terms of efficiency, speed, code-size, pre-compilation/post-compilation, and things like that.
And please give examples ...
This sounds suspiciously like you've got a take-home exam in a programming course, and you're looking for us 'geeks' to provide the answers.
I'll give you the answer to your question. My rate is $75USD/hr (you're getting the student discount, BTW), 4 hours minimum, in advance, in cash.
Software Zen: delete this;
|
|
|
|
|
Is that something you say when you dont know the answer Mr?
Anyway a proper answer would have been appreciated. I was asked this questionj at a job interview. When i will get the job, i will pay u. LOL
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Hi einstines,
i was asked this question at an interview:
class a<br />
{<br />
};<br />
main()<br />
{<br />
cout<<sizeof(a); <br />
}
I can obviously run the program to find the output but i need an explanation about the output.
PLEASE ANSWER: WHAT IS THE OUTPUT????
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
i did just that in VC++
class A
{
};
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int i = sizeof(A);
cout << "Sizeof A:" << i << endl;
}
it displayed 1.
I switched to assebmly listing and the linker has generated the following code:
77: int i = sizeof(A);
004018AB mov dword ptr [i],1 <----- Notice here, the linker knew its an empty class and automatically replaced its size by 1
78:
79: cout << "Sizeof A:" << i << endl;
004018B2 mov esi,esp
004018B4 mov edx,dword ptr [__imp_?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z
004018BA push edx
004018BB mov edi,esp
004018BD mov eax,dword ptr [i]
004018C0 push eax
004018C1 mov ebx,esp
004018C3 push offset string "Sizeof A:" (004130d4)
004018C8 mov ecx,dword ptr [MSVCP60D_NULL_THUNK_DATA (00415234)]
004018CE push ecx
004018CF call dword ptr [__imp_??6std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z (004
004018D5 add esp,8
004018D8 cmp ebx,esp
004018DA call _chkesp (004014bc)
004018DF mov ecx,eax
004018E1 call dword ptr [__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z (0041523c)
004018E7 cmp edi,esp
004018E9 call _chkesp (004014bc)
004018EE mov ecx,eax
004018F0 call dword ptr [__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01
004018F6 cmp esi,esp
004018F8 call _chkesp (004014bc)
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Ya, thanx for ur reply and to tell the technique to see linker output (thats a new thing i learnt)
But, why 1? is it property of the linker or a C++ standard to make size of an empty class as 1. Please tell.
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|