|
If you are using VC++ 7, then you can use CImage class. If you don't but have the latest Platform SDK, then can use the Image class of the new GDI+ library. If neither, then download the CXImage class from code project.
All this classes with allow you to access to an HBITMAP that you can use it anywhere.
|
|
|
|
|
With an MFC Menu, is it possible to not just disable but *hide* menu items without having to delete them from the menu?
|
|
|
|
|
Yes, it's possible, but not recommended, it confuses the user that sometimes a menu item is visible, and sometimes it's not.
look for :
BOOL CMenu::RemoveMenu( UINT nPosition, UINT nFlags );
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Thank you but RemoveMenu() deletes the item from the menu. I just want to hide it so that I can easily restore it when a different document is shown.
|
|
|
|
|
you need to remove it to hide it.!
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
I am just brainstorming here because I have never tried this but what if you use two different menu bars, one with all the menu options and the other with certain menus hidden? I don't even know if it can be done, but you can try it.
Max is right though, if you want to hide it you have to remove it.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
OnKeyDown does not seem to be getting called in this case at all. Any ideas what needs to be done in order for the keyboard accelerators to start working and keyboard inputs to get recorded?
Thanks in advance!!!
LRESULT TestPage::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
MSG msg;
HACCEL hAccel;
BOOL bRet;
if (!m_hWnd)
return FALSE;
hAccel = ::LoadAccelerators( _Module.m_hInstResource, MAKEINTRESOURCE(Accel));
if (m_hAccel == NULL)
return FALSE;
while ((bRet = ::GetMessage(&msg, m_hWnd, NULL, NULL)) != 0)
{
if (bRet == -1)
{
return FALSE;
}
else
{
if (!::TranslateAccelerator( m_hWnd, m_hAccel, &msg))
{
MessageBox ("Key Pressed ","Accelerators",MB_OK);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
return TRUE;
}
|
|
|
|
|
Hi
I've followed the following tutorial about implementing contextsensitive help:
http://www.codeguru.com/misc/csh_dialog.shtml
But the tutorial doesn't work .. i alsoo get 'Help topic is not found' .. Does anyone know what the problem is? Or can anyone post a fix or something?
I'd appreciate it greatly.
Best regards
Jens
|
|
|
|
|
Hi, everyone!
Please look at the following codes. In function(), the return
value is a reference type, but it is assigned to an object. I
think reference type and origin object type are two kinds of
things. We often assign an object to a reference. But what about
the contrary? And this is my first question.
I have learned from others before that reference is just a alias
of the other object. But in the following case I am not sure. Because
the returned reference is pointed to a temorary object. And it can
be printed in main!! And this is my second question.
Who can help me with my two questions?
Source Code:
--------
#include <iostream>
using namespace std;
class foo {
public:
void Echo()
{
cout << "Hmm..." << endl;
}
};
foo& function()
{
foo obj;
return obj;
}
int main()
{
foo obj = function();
obj.Echo();
return 1;
}
--------
Thanks in advance,
George
|
|
|
|
|
We often assign an object to a reference. But what about
the contrary? And this is my first question.
It is perfectly legal, the reference is treated as the object it is bound to. For instance:
int i=0;
int& ir=i;
int j=ir;
j=5; As for your second question, returning a reference to a temporary leads most likely than not to catastrophe. Your example is working out of sheer luck. The problem is that your foo function returns a reference that is bound to an object which gets destroyed as soon as foo exits. By the time the caller uses the reference, this is bound to a non-existent object.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddy!
I have thought my sample a little deeper. I think
when "return" statement is called, a reference to the
temporary object is generated and finally the reference
to the "obj" object is returned to the client code.
Am I correct?
I often the type of a function returns a reference.
In your opinions, I think it is dangerous usage. But
the usage is too often -- return a reference type.
Can you explain it a bit deep?
I think return a reference of a function local object
is illegal. Am I correct?
regards,
George
|
|
|
|
|
Returning a reference is not dangerous in general, only if the reference is to a temporary object. The rule is: you can safely return a reference to an object from a function if the object lives longer than the function. For instance, the following example is perfectly safe:
class A
{
private:
std::string str;
public:
std::string& get_str()
{
return str;
}
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddy!
George
|
|
|
|
|
Insert CPropertySheet in SplitterWnd? How?
Hello,
how can insert in a child of SplitterWnd a CPropertySheet?
I know that the CPropertySheet is'nt a CView deriviates.
But is there any way, which I can include CPropertySheet ?
Thanks for any helps. jr
|
|
|
|
|
this is what I use in order to create a property sheet inside a dialog... (I suppose that it will work in the same way...).
this->m_pPSEstacio = new CPSEstacio("", this, 0);
this->m_pPSEstacio->Create(this, WS_CHILD | WS_TABSTOP | WS_VISIBLE);
this->m_pPSEstacio->ModifyStyleEx(0,WS_EX_CONTROLPARENT);
Hope this helps...
PS:
you've obviously to change the the parents (this pointers) to the ones needed (the view where you want to insert it)...
|
|
|
|
|
Only a note:
If you want that all the view become a property sheet, you should change the base class of the view you want to change for the CPropertySheet.
|
|
|
|
|
Hello,
I have an applilcation wich requires several tools (but without knowing the existence of them). So, all of these tools are defined in a add-in dll and they all inherit from a common class (say CGenericTool).
This works fine but what I want to do now is that I want to produce several different dll depending of what tools the client require. So, in the dll I will have a function that 'tells' to the main application wich tools are available in it.
I have a "ToolFactory" class that produces the tools (based on the COM technology) and I want to ask this class wich tools it can produce. I want it to be very easy to add or remove tools. I though of something like this: in the file where the factory is define, I just have to add or remove the header file from the specified tool and the class would automatically knows about that!
Something like:
#include "stdafx.h"
#include "ToolFactory.h"
#include "GenericTool.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
CToolFactory::CToolFactory()
{
}
CToolFactory::~CToolFactory()
{
}
HRESULT CToolFactory::CreateTool(CGenericTool** ppObject, int ToolType)
{
switch (ToolType)
{
#ifdef TOOL1_H
case TOOL1:
*ppObject = new CTool1;
return NO_ERROR;
#endif
#ifdef TOOL2_H
case TOOL2:
*ppObject = new CTool2;
return NO_ERROR;
#endif
default:
return -1;
}
return NO_ERROR;
}
int GetToolAvailable()
{
int Count = 0;
#ifdef TOOL1_H
Count++;
#endif
#ifdef TOOL2_H
Count++;
#endif
return Count;
}
Do you think it's a good way to do this ?? Or do you know any better idea??
I'm waiting for all your suggestion and ideas
Moonen Cédric
|
|
|
|
|
Hi!
I need a lib or something like that to draw trees or networks or everyhing that looks like nodes bound together with lines (like in Matlab/Simulink for example).
Do we have that here on CP ?
~RaGE();
|
|
|
|
|
I haven't seen anything on CP. In my experience, commercial graphing/layout libs aren't cheap.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hello,
I'm trying to directly set the html in a web browser (CWebBrowser2) control using something like
m_browser.SomeMethod("<html><body>Hello, World!</body></html>")
Is this possible, using either a direct method or by getting an interface to the document properties? I can't find a list of the properties anywhere on MSDN or on the web.
If all fails I will just save the text to a temporary file and get the browser to navigate to the file.
Thanks,
John
|
|
|
|
|
Hello,
I'm doing an app in which I read a video file frame by frame. Once the "play" button has been pressed, I grab the next image until a "pause" button has been pressed.
I grab the message indicating that the pause button has been pressed with the peek method :
while( ::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)){
if((user_paused)&&(msg.message == BN_CLICKED)&&(msg.wParam == IDC_BUTTON_PAUSE)){
// stop the video
break;
}
if((msg.message == BN_CLICKED)&&(msg.wParam == IDC_BUTTON_CAPTURE)){
// continue the video but show the captured frame
}
if (!AfxGetApp()->PumpMessage()){
::PostQuitMessage(0);
return;
}
}
The message is grabbed since my video pauses but the loop never stops although I had a loop on a boolean user_paused which I put to true when the user presses on the pause button.
Since I don't understand exactly how the peek & pump function work, I don't know what's wrong. Could anyone help me ?
Thank you.
|
|
|
|
|
sandrineV wrote:
The message is grabbed since my video pauses but the loop never stops although I had a loop on a boolean user_paused which I put to true when the user presses on the pause button.
Not possible. It had to stop. Try :
bool bVideoPlaying;
while(bVideoPlaying)
{
::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE);
if((user_paused)&&((msg.message & BN_CLICKED)==0)&&((msg.wParam == IDC_BUTTON_PAUSE))
{
bVideoPlaying=false;
break;
}
else if(((msg.message & BN_CLICKED)==0)&&(msg.wParam == IDC_BUTTON_CAPTURE))
{
PlayVideo()
}
if (!AfxGetApp()->PumpMessage())
{
::PostQuitMessage(0);
return;
}
}
Here, if the video stops, it will exit the while loop, whatever happens.
Is sandrine your forename ? It sounds french...
~RaGE();
|
|
|
|
|
How to set WS_EX_TOPMOST style to a dialog window at runtime? I'm trying with ModifyStyleEx function but it's not working. Am I missing something?
|
|
|
|
|
Try SetWindowPos() with HWND_TOPMOST
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi
I've made a menu named 'IDR_MAINFRAME' (CMainFrame) which is loaded into the project.
This is the dutch version of the menu.
Now i want to be able to change some menu-captions at runtime.
I've looked up a few things @ MSDN but doesn't seem to work tho
I've tried to change the menu @ runtime like this:
void CMainFrame::OnShowWindow(BOOL bShow, UINT nStatus)
{
CFrameWnd::OnShowWindow(bShow, nStatus);
//Check wheither dutch or french version
if ( !bDutch )
{
PutMenuIntoFrench();
//This will change a menu-caption into something else
}
}
void CMainFrame::ZetMenuInFrans()
{
CMenu* pMenu = GetMenu();
int iPos;
iPos = FindMenuItem(pMenu, "&Message");
pMenu->ModifyMenu(iPos, MF_BYCOMMAND, iPos, "&Voir Remarque");
}
FindMenuItem(..) was provided into some code @ msdn:
int CMainFrame::FindMenuItem(CMenu * Menu, LPCTSTR MenuString)
{
ASSERT(Menu);
ASSERT(::IsMenu(Menu->GetSafeHmenu()));
int count = Menu->GetMenuItemCount();
for (int i = 0; i < count; i++)
{
CString str;
if (Menu->GetMenuString(i, str, MF_BYPOSITION) &&
(strcmp(str, MenuString) == 0))
return i;
}
return -1;
}
Anyone knows what the problem might be?
Would appreciate it much
Greetings
Jens
I already found the error:
pMenu->ModifyMenu(iPos, MF_BYPOSITION, id, "&Mytext");
i didn't check the param. very well
so everything works fine now
The only thing that bothers me is that this check is always performed OnShowWindow. It only needs 1x to be executed. I have a form where the user can select language: dutch / french
Can i call CMainFrame::ChangingOfMenu() there somewhere?
Greetings
Jens
Cyaz
|
|
|
|