|
BOOL CMySheet::OnInitDialog() {
CPropertySheet::OnInitDialog();
// this hides the Help button
CWnd* pHelpButton = GetDlgItem (IDHELP);
ASSERT (pHelpButton);
pHelpButton->ShowWindow (SW_HIDE);
return TRUE;
}
|
|
|
|
|
thanks for your suggestions.
|
|
|
|
|
Write the following code in constructor of every property page which is added in to the property sheet
m_psp.dwFlags &= ~(PSP_HASHELP);
Thanx
TAKE CARE
|
|
|
|
|
hi thanks for suggest it's working.
|
|
|
|
|
Hi
I am doing following set of activities...
1) Compiled an IDL file to get TLB, registered it using regtlb32 and is available in OLE/COM viewer
2) Compiled the project (which is supposed to generated the DLL). In Project settiongs, I have got following lines as Custom Build Setup
<br />
regsvr32 /c "$(TargetPath)"<br />
echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"<br />
When I compile this project, IDE says "DllRegisterServer in f:\MyWork\ProjectX.dll succeeded."
But when I try to register manually (regsvr32 f:\MyWork\ProjectX.dll), it gives error...
LoadLibrary("f:\MyWork\ProjectX.dll") failed - The specified module could not be found.
Basically this project is written in VC 5/6 and I am compiling it in VC++ .NET. Any suggestions?
HELP!!!!!!!!!!
stuck lil' ol' mE
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
You have probably problem with some missing dependency dll - I assume your manual registration is on another computer.
Use the dependency viewer to see what DLL's are required to run the dll.
|
|
|
|
|
geo_m wrote:
assume your manual registration is on another computer.
Now this is the problem... I am doing this on same machine... Wish I could show you!!!
This is happening on same machine - I compile, says okay done, but when I minimize the IDE and then try to register on command prompt, it says can't... Helpppppp!!!!!!!! plzzzz......
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
void CDllRegisterServerDlg::RunDllFunc(CString strFuncName)
{
CString strMsg;
UpdateData(TRUE);
HINSTANCE h=::LoadLibrary(m_strDllName); //dll name
if(h == NULL)
{
strMsg.Format("Find not File: %s.", m_strDllName);
MessageBox(strMsg,"Find File",MB_OK);
return;
}
FARPROC pFunc= ::GetProcAddress((HMODULE)h,strFuncName);
if(pFunc ==NULL)
{
strMsg.Format("Find not %s Function");
MessageBox(strMsg,"Find Function",MB_OK);
return;
}
if(S_OK==(*pFunc)())//(*pFunc)())
{
strMsg.Format("Ok: %s to %s succeeded.",strFuncName,m_strDllName);
}
else
{
strMsg.Format("Eorr: %s to %s eorr.",strFuncName,m_strDllName);
}
MessageBox(strMsg);
}
Use these code on debug mode, you can find the dll file which you missed~
|
|
|
|
|
Thanks for your reply... I will check this out and will let you know here.
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
Directly comaring 2 vectors is pretty good.
However, if we try to compare 2 vectors in a class, problem ocurs.
Please see the following code.
#include<iostream>
#include<vector>
using namespace std;
class A
{
public:
typedef vector<int> vect;
private:
vect v;
public:
A(int dim, int* a)
{
v.reserve(dim);
copy(a,a+dim, v.begin());
}
// what's wrong here
bool operator==(const A& other) const
{
//cout<<v[0]<<','<<v[1]<<endl;
cout<<other.v[0]<<','<<other.v[1]<<endl;
="" return="" v="=" other.v;=""
="" }
};
void="" main()
{
="" initiate="" 2="" arrays
="" int="" a[2]="{1,2};
" b[2]="{2,2};
" cout<<"******="" vector="" compare="" ******\n";
="" vector<int=""> v1(a,a+2);
vector<int> v2(b,b+2);
if(v1==v2)cout<<" equal\n";
else cout<<"not equal\n";
cout<<"****** class A compare ******\n";
A object1(2,a);
A object2(2,b);
if(object1 == object2) cout<<" equal\n";
else cout<<"not equal\n";
}
run:
****** vector compare ******
not equal // OK, (1,2) not_equal_to (2,2)
****** class A compare ******
equal // oops (1,2) equal_to (2,2), Jesus knows???
zma64
|
|
|
|
|
A(int dim, int* a)
{
v.reserve(dim);
copy(a,a+dim, v.begin());
} Here lies the problem. vector::reserve does not change the size of the vector; it merely reserves some space so that future changes in size are more efficient (i.e. does not require relocations of the elements). So, v.size() will still be 0 after the operation, and the call to copy has undefined effects (you're copying the elements pointed to by a into nowhere.)
The simplest solution is to replace the call to reserve with
v.resize(dim); which does change the size of v . A more efficient approach is
#include <iterator>
...
A(int dim, int* a)
{
v.reserve(dim);
copy(a,a+dim, back_inserter(v));
} but depending on your STL skills this may look a little odd to you. Basically, this is more efficient because you are not default initializing the elements of v before doing the copy.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz:
Thank you. Your reply help me a lot.
marshal
|
|
|
|
|
I wonder do the real world programmer write "precondition"
and "postcondition" in the comment? Because, right now in
my programming class, the instructor requires us to use
it in the comment. For example:
// Precondition: n > 0
// Postcondition: The user has been asked to think of a number
// between 1 and n. The function asks a series
// questions, until the number is found.
void guess_game(int n)
{
int guess;
char answer;
assert(n >=1);
.
.
.
.
}
|
|
|
|
|
Preconditions are very useful, however separating the assertion from the comment explaining the test is a bad idea IMO. Put the comment right above the assertion, so that when the assert fails and the debugger drops you at that line, the comment is right there explaining it.
Also, "n > 0" is a useless comment. No duh. That comment does nothing to explain why n is being tested. Something more useful would be:
void guess_game ( int nChosenNumber )
{
assert(nChosenNumber >= 1);
} As for postconditions, I've never used them. Assertions placed after key blocks of code, as a sanity check that the result isn't something out of the expected range, is more useful, again IMHO. Such a sanity check placed at the end of a function could be seen as a postcondition, I guess.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
CP SearchBar v2.0.2 released
|
|
|
|
|
So you do use precondition, BUT you do not write "precondition"
explicitly like the one that in my example?
Well, what is the formal difinition of "assertion"? Is it
kind of precondition?
|
|
|
|
|
VW_Red_Jetta wrote:
Well, what is the formal difinition of "assertion"?
I'll provide you a comment from Steve McConnell:
The main difference between "if" tests and assertions is that assertions should test for conditions that you expect *never* to happen; "if" tests are for conditions that you plan to deal with. Assertions should not take the place of normal error-processing code. They should be used to flush out defects in your code. Put differently, an assertion should never fire unless there is a defect.
When I posed a similar question to Steve Maguire (my function had a signature of Foo( LPSTR ) ), his response was:
The question you should ask is this:
Is it legal for another programmer to call
Foo() with a null pointer?
or phrased differently:
If a programmer passed NULL to Foo(), would
that be a bug in the calling code?
If you decide that getting NULL is an illegal condition (based on how you designed Foo()) and indicates a bug in the calling function, then you should use ASSERT. If, on the otherhand, Foo()'s design makes getting a NULL pointer reasonable, and would not indicate a bug in the caller, then you should be using the "if".
You may want to use both the ASSERT and "if". You'd use both when getting a NULL would indicate a bug, and when you'd still want the code to behave intelligently even when it gets garbage. The typical scenario would be aircraft controller software, or radiation machine software. Bugs in either of these pieces of software could be deadly and so you'd keep the "if" just in case a bug makes it into the final code. Hopefully the ASSERT would alert you to the bug long before then.
Probably the best way to figure out whether to use an ASSERT or an "if" is to follow this guideline:
Completely finish the function as you intend
to ship it. Once you're convinced that you've
got the code as you plan to ship it, _only then_
do you add assertions (and debug code), _without_
changing what your ship code does.
(Remember, debug code is strictly _extra_ code.)
Using this guideline, you can see that if your ship code has to handle NULL pointers, then you have to use an "if" statement to handle the NULL pointer. If the ship code doesn't have to handle the NULL pointer, then you can ASSERT that getting one is illegal so that it alerts callers to their bugs.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Well thank you very much for the formal of assertion. So
do you explicitly write "precondition" and "postcondition"
in the comment?
|
|
|
|
|
VW_Red_Jetta wrote:
So
do you explicitly write "precondition" and "postcondition"
in the comment?
Neither.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hello, everyone!
I know nothing abuot mmap. And are there some tutorials or simple sample codes about mmap? I just want to learn the basic usage of mmap.
regards,
George
|
|
|
|
|
Hi all,
I am attempting to hook the keyboard to allow it to behave as a mouse device. The application works fine on 2K and XP but not on 98 or ME. If the controlling application Window is active all works fine but if it isn't things go pear shaped. This would indicate to me that I am not get a system hook rather a thread one, but that seems improbable given it works on other platforms and the hook code resides in a dll.
Any ideas?
Here is the code I use to hook the event:
/**
* Installs the hook.
*/
KEYHOOK_API bool InstallKeyboardHook()
{
if(g_hKeyboardHook == NULL) {
g_hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, g_hInstance, NULL);
}
// Fail if the hook fails to install
if(g_hKeyboardHook == NULL) {
return false;
}
return true;
}
/**
* Removes the hook
*/
KEYHOOK_API void RemoveKeyboardHook()
{
while(!UnhookWindowsHookEx(g_hKeyboardHook)) {
Sleep(100);
}
g_hKeyboardHook = NULL;
}
/**
* Called by the hook when there is a keyboard event.
*/
KEYHOOK_API LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode >= 0) {
// Check to see if the action belongs to the space key, if so we trap it
if(wParam == VK_SPACE) {
// Only perform an action if the space key is being released
if((::GetAsyncKeyState(VK_SPACE) & 0x80000000) != 0x80000000) {
// Determine the controller and perform the appropriate action
if(GetController() == SI_SCANNER) {
SetClicked();
}
else if(GetController() == SI_MOUSE) {
SetState((GetState() + 1) % NUM_STATES);
}
}
// Trap this message
return 1;
}
}
return CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam);
}
|
|
|
|
|
I have been trying for quite some time now to download the Platform SDK from the msdn website. The mickeysoft program that is supposed to handle the installation keeps crapping out with a "Server Error" message. I can't download the CAB files either because they are coming in corrupted. Is there another way to obtain the SDK?
Thank you,
Eric Sepich
|
|
|
|
|
|
Greetings,
I would like to write a generic CPhaseManagement object, but keep hitting a wall with it being tied to the specific app. The Phases would be something like: InitPhase, IntroPhase, MenuPhase, AppPhase, and ExitPhase with an enumerated type defined in a PhaseSettings.h file !
Each Phase of the App will have it's own specific Phase routines (StartPhase, ProcessPhase and ExitPhase). These of course will be App specific.
So I need to know how to make a pointer to a function so that the PhaseManager can call the relevant PhaseStart/exit etc.
Any pointers (haha) / comments appreciated.
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
int Foo1( WPARAM, LPARAM )
{
}
int Foo2( WPARAM, LPARAM )
{
}
int (*pFunc)( WPARAM, LPARAM );
if (some_condition)
pFunc = Foo1;
else if (some_other_condition)
pFunc = Foo2;
(*pFunc)(parameter_list);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
cast to pointer to Function hey !
Who would have thought!
(Obviously not me)
Much Appreciated
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|