|
Call DeleteMenu on the existing items.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
window crashed/rebooted when testing.
so what's next... creating a system menu, how? please advice.
|
|
|
|
|
i wanna define a global variable in mfc application, someone told me to use extern but that wont works. but is gives still same error "Variable already defined in project.obj"
|
|
|
|
|
First, put it in a .h file that is shared by all members (stdafx.h is a good place.) Second, if you don't put it in stdafx.h, be sure to wrap it like:
#ifndef _MY_GLOBAL_VAR
#define _MY_GLOBAL_VAR
sometype m_someglobalvar;
#endif
Lastly, you must istantiate the variable in a .cpp file (stdafx.cpp is a good place).
One suggestion, though. If you really need a global variable, consider making it a static member of a class or at least provide get/set functions for it instead of fully exposing the variable.
|
|
|
|
|
Speedy wrote:
someone told me to use extern but that wont works
They are right - you are doing it wrong.
in stdafx.h
extern int m_nGlobalsAreEvil;
in stdafx.cpp ( thanks to Matt for pointing out my typo... )
int m_nGlobalsAreEvil;
By the way, globals are evil. As has been said, static variables are a better option. In a class, do
static int m_nThisIsMuchBetter;]
If this was done in class A, you can do this:
A:m_nThisIsMuchBetter = 0;
If you don't want to do that, at LEAST wrap your global in a namespace.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Christian Graus wrote:
in stdafx.h
int m_nGlobalsAreEvil;
I think you ment stdafx.cpp
And yes, globals are evil.
|
|
|
|
|
Matt Gullett wrote:
I think you ment stdafx.cpp
Yes, I did. Thanks.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Hi,
I am sure this is an easy one, but I cannot get this information intercepted.
I have an Edit View and want to know when the user presses space whilst the left ctrl key is held down.
Is this possible?
Thanks in advance,
Simon
|
|
|
|
|
3 ways I can think of do do this:
1) Create an accelerator and handle it in your view class.
2) Overide the WM_KEYDOWN message and check for the space key and call GetAsyncKeyState (or is it GetKeyState) to see if the control key is down.
3) Overide the PreTranslateMessage function, check for WM_KEYDOWN and do step 2.
|
|
|
|
|
Hi Matt,
Thanks for the response, you put me in the right place!
I handle WM_KEYDOWN already, so I elected for option 2, and you are right to mention GetKeyState. It works when I do the following:
if((nChar == 32) && (GetKeyState(VK_CONTROL) >> 7) == -1))
{
// it happened
}
Is this how you would expect to do it?
Simon
|
|
|
|
|
I am responding to system shut down with the help of WM_QUERYENDSESSION but the problem is before i respond to this message some applications are being closed which are sitting in the Task bar tray and also some open applications in the task bar.I don't want this to happen.Is there any way to be the first in trapping WM_QUERYENDSESSION session and avoid other applications being killed.
|
|
|
|
|
You can intercept (and block) this message by installing a system-wide hook with <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/CommCtls/winui/hooks_7vaw.asp">SetWindowsHookEx</a> .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Below is the code snippet i used for HOOKING the WM_QUERYENDSESSION.But i never see the message box i am displaying.
1.Is there any problem with the below code
2.Also how can i discard the WM_QUERYENDSESSION at this moment so that it will not reach other applications.
DLL_EXPORT void SetHook(void)
{
if(!bHooked)
{
hhook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)MsgProc, hInst, (DWORD)NULL);
bHooked = TRUE;
}
}
LRESULT CALLBACK MsgProc(int code, WPARAM wParam, LPARAM lParam)
{
MSG* msg;
msg = (MSG*) lParam;
if( code >= 0 )
{
if( msg->message == WM_QUERYENDSESSION)
{
MessageBox( NULL , "Recieved WM_QUERYENDSESSION" , "test" ,
MB_OK|MB_APPLMODAL|MB_SETFOREGROUND|MB_TOPMOST
);
}
}
return CallNextHookEx(hhook, code, wParam, lParam) ;
}
|
|
|
|
|
Is there any way to separate IWebBrowser2 and its document? IWebBrowser2 has an get_Document() function. I want something like put_Document . So I can "switch" documents of the browser. Like you do in a View (even in SDI).
Does anyone know how to do that and if it is possible at all?
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Why not create temporary html files with the different "documents" and just Navigate to them when needed?
Cheers!
Marc
|
|
|
|
|
Use document.write(...) method.
|
|
|
|
|
Well, I even can store all HTML in IStream and load again (will be faster) or use document.write() as ADK says below. But in all 3 ways, the document will be disconnected from the actual site. Links won't be resolved properly. Of course I can change links from relative to full, then all will work correctly, but... Something tells me that this is not the right way
Well, I don't think I can do what I wanted to do, but I found another solution, workaround Since I can't change Document of the browser... I can change the whole window . Just like in with CView . The only disadvantage I see, that I will have additional Browser control (IWebBrowser2 ) for each window.... But I guess this is the price
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
I've been searching the site for some version of a tabbed control that looks similar to the Excel tab control for the doc/view windows. I did run across an old MSJ article that looks OK, but not quite full featured. Before I go and pretty that one up, I was wondering if I'm missing one on this site? Any suggestions???
Rob
|
|
|
|
|
Hi, I'm a newbe with a problem, any help would be appreciated.
I've got a combobox that lets you enter text as well as select an item from the list, what i want is to call a function when the user has typed in the text and pressed enter, but i cant find out if they've pressed enter. I've tried putting code in the OnEditchange section and looking for a carriage return in the entered string but it doesn't work. Any ideas?
Thanks
|
|
|
|
|
FWIW, my first two guesses would be either the CBN_SELENDOK notification message, or subclassing the ComboBox and handling WM_KEYDOWN or capturing it inside of PreTranslateMessage(...) .
Peace!
-=- James.
"Fat people are hard to kidnap."
(Try Check Favorites Sometime!)
|
|
|
|
|
Hi there,
I'm trying to implement the following function using STL algorithms.
The function will just transform a bunch of data bytes to its hexadecimal representation in string format (readable in output screen).
prototype:
--------------------------------------------------------------------------------
/*
* example
* Input char [] = {0x0 , 0x1 , 0x2 , 0x3 ,0x10 }
* Output String = "000102030A"
*/
const std::string dataToHexSring(const char *);
--------------------------------------------------------------------------------
Here is what I got. It does not implement "dataToHexString" or even pretend to do similar, but gives you a guidelines about all the mistakes i'm doing, and the way I'm implementing it.
NOTE: It doesn´t compile
--------------------------------------------------------------------------------
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>
const std::string func ( const char s ) {
return "FF";
}
int main ( void ) {
const int sz = 20;
char data [] = { 0x0, 0x1, 0x2, 0x3, 0x4 }; //original data
std::string tdata; //should end up with "0001020304";
std::vector <std::string> vs;
//std::copy(data.begin(),data.end(),std::back_inserter(vs));
std::transform(data,data + 5,std::back_inserter(vs),
std::ptr_fun(func));
//std::cout << "vecString t :" << vs << std::endl;
return 1;
}
--------------------------------------------------------------------------------
Any suggestion, improvment or word about the code is appreciated.
Looking forward for your replies.
Regards.
Carlos.
|
|
|
|
|
You code seems perfect. Is it not working? What errors are you getting?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
OK, now that I've got a compiler handy could I try your program.
The problem stems from the inability of std::ptr_fun to handle const arguments. If you declare func as const std::string func ( char s ) your program will compile. Alternatively, you can omit the use of std::ptr_fun altogether and pass func directly, with its const args and all.
As for the lots of warnings appearing, in case you don't know they're innocuous and can be eliminated with #pragma warning(disable:4786)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi All,
I would like to find an example of declaring a pointer to a member function. I would like to be able to call member functions of a derived class, by name, through a pointer to a base class. Something like this:
CBase
{
// A member function that takes no args . . .
typedef ??? MemberFunctionPointer
double Calculation(const std::string& idx)
{
if(m_map.end() == m_map.find(idx))
return; // No such function
MemberFunctionPointer func = m_map(idx);
double result = *function;
}
void RegisterFunction(const std::string& strName, MemberFunctionPoint pFunc)
{
m_map[strName] = pFunc;
}
}
class CTrig : public CBase
{
double pi {return 3.1415;}
CTrig()
{
CBase::RegisterFunction("pi", this->pi);
}
}
CBase* pBase = new CTrig;
double result = pBase->Calculation("pi");
So how about it? What should the typedef look like?
Thanks,
Aaron
|
|
|
|
|
The syntax is tricky, and I don't have any ocmpiler handy, but it must be something like:
typedef virtual double (CBase::* MemberFunctionPointer)(); The virtual bit is necesarry to ensure that the proper derived class is handled in the call.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|