|
After finding the creation of view by MFC, i feel it's pretty implicit(created in CreateObject() ).
|
|
|
|
|
How do I change the cursor when the mouse pointer is on a button or on a notified picture???
|
|
|
|
|
There is a message WM_SETCURSOR. Deal with in your control and your are ready.
Try it @ home. (B&B)
|
|
|
|
|
use setcursor() on focus message handler
|
|
|
|
|
Can we get a little more help on this issue. I have been trying to do this for the past week but no luck...I have four ownerdrawn windows on my main window for which I would like to use the hand cursor like in internet explorer but all I get is the stinken' arrow. Here is the code that I use.
WM_MOUSEMOVE:
x = LOWORD (lParam);
y = HIWORD (lParam);
RECT rect;
GetWindowRect(hwndView, &rect); // Handle to one of the owner drawn buttons
if ( ( x >= rect.left && x <= rect.right ) &&
( y >= rect.bottom && y <= rect.top )
)
ShowCursor(hCursor);
break;
All with no luck...Is there a difference in the coordinates of the mouse and the ones received by GetWindowRect? If so shouldn't the mouse cursor appear somewhere else on the window...for me, just the stinken' arrow
|
|
|
|
|
anonymous wrote:
Is there a difference in the coordinates of the mouse and the ones received by GetWindowRect?
Yes! As MSDN clearly states (in the entry for WM_MOUSEMOVE ):"The coordinate is relative to the upper-left corner of the client area."
So a simple ClientToScreen() on the mouse coordinates should help.
|
|
|
|
|
Thanks for the help, finally got it working but it wasn't the screen coordinates that were the problem. I didn't pay attention to the fact that WM_MOUSEMOVE is posted TO THE WINDOW THE CURSOR IS UNDER! In my case the buttons so what I needed to do is basically subclass the window which worked great...thanks for your help...I do have another question on this if you could help me with it. Although not a tragedy, when I click on the button now the cursor changes to an arrow and then back which is fine because it is a quick change but for other buttons which invoke dialog boxes then the cursor stays into an arrow over the button where it should be a hand. Is there a way to make the cursor be a hand until it is out of the window regardless of clicking?
|
|
|
|
|
I've been trying to add panes to a Status Bar, and have run into problems with the MS documentation about doing so. Similarly, I've searched the CodeProject list of articles to see if there might be examples on this subject.
Does anybody know of any, or a website, or anything?
Thanks. I appreciate it.
William
|
|
|
|
|
I did the following in my CMainFrame::OnCreate() function. I have a SDI application and wanted a button added to the status bar.
It may not be what you are looking for, but may inspire you in the correct direction.
// The following code allows a button to be added to the status bar
// Add an indicator, with width, ..
m_wndStatusBar.AddIndicator( 1, IDC_BUTTON_STATUS_BAR );
int idx = m_wndStatusBar.CommandToIndex( IDC_BUTTON_STATUS_BAR );
m_wndStatusBar.SetPaneWidth( idx, 15 );
m_wndStatusBar.SetPaneStyle( idx, m_wndStatusBar.GetPaneStyle( idx ) | SBPS_NOBORDERS );
// Create a pane window, and append it to status bar
m_pBtnCommStatus = new CButton;
m_pBtnCommStatus->Create( _T(""), WS_CHILD | WS_VISIBLE | BS_FLAT | BS_BITMAP, CRect(0, 0, 0, 0), &m_wndStatusBar, IDC_BUTTON_STATUS_BAR );
HINSTANCE hInstance = AfxGetInstanceHandle();
// Set the Icon for the button on the status bar.
m_pBtnCommStatus->SetBitmap( ::LoadBitmap( hInstance, MAKEINTRESOURCE(IDB_BITMAP5) ) );
m_wndStatusBar.AddControl( m_pBtnCommStatus, IDC_BUTTON_STATUS_BAR );
Hope this helps
regards
|
|
|
|
|
CMyClass
public:
CMyClass(void);
~CMyClass(void);
#include "stdafx.h"
#include "myclass.h"
CMyClass::CMyClass(void)
{
}
CMyClass::~CMyClass(void)
{
}
When compiling it generates:
c:\x\Project\myclass.cpp(6): error C2533: 'CMyClass::CMyClass' : constructors not allowed a return type
???
Any ideas?
|
|
|
|
|
Did you have the keyword "class" preceding "CMyClass" along with the appropriate braces in its definition?
William
|
|
|
|
|
yes, I just forgot to indicate it my post.
BTW: the class was generated by "add class/generic c++ class"
after eliminating everything that is the full code:
#pragma once
class CMyClass
{
public:
CMyClass(void);
~CMyClass(void);
}
<pre>
<pre>
#include "stdafx.h"
#include "myclass.h"
CMyClass::CMyClass(void)
{
}
CMyClass::~CMyClass(void)
{
}
and that the new error message:
c:\x\Project\MyClass.cpp(6): error C2533: 'CMyClass::__ctor' : constructors not allowed a return type
|
|
|
|
|
Other than the semicolon missing at the end of the class definition (which the compiler would have caught anyway and you would've fixed already), I don't see anything erroneous in the way you have declared and defined the ctor.
Everything looks correct which means the real error is NOT with your constructor. The real error will be with something the compiler didn't like before it reached the constructor. If there is nothing between the class definition and where the constructor appears in it, then the problem is NOT with the way you have defined the class. The problem will be with something that appears before the class definition.
You can rule out there is something wrong with the class and its ctor, and look somewhere else ahead.
William
|
|
|
|
|
It is the missing semicolon. The compiler thinks you are trying to return the class.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
need ~CMyClass() ,This function can't have vairable to pass!!!
|
|
|
|
|
a new workspace solved the problem. The old workspace without the newly added class still compiles fine. Strange thing.
Anyway thanks for your help.
|
|
|
|
|
Hello,
I have created a CListCtrl derived class that includes a CEdit and a CComboBox that are created in the PreSubClassWindow function of the derived class.
I create the CEdit and the CCombobox using their respective ID.
But what can happen if I create two ListCtrls at the same time? (then 2 CEdit (and two CComboBox) with the same resource ID would be working at the same time)
Could this fact be a problem?
If so, how could I avoid that fact...
Thank you in advance.
|
|
|
|
|
In this case you have a problem with all functions that use resource ID as parameter, like GetDlgItem. Control itself works nice like all static controls and frames in dialog which have the same resource ID IDC_STATIC. In your case it's better to talk with CEdit and CComboBox from CListCtrl using their pointers and handlers and not resource IDs.
|
|
|
|
|
Hello,
I have problem with _outp, _inp function.
Its simple, these functions are not supporten in Windows NT,2000 and so on.
Amd I've got aplication working well on Win.9x and i like to use it on NT platforms.
But how can I substitute this function?
(best is to find way usable on both: Win9x and NT)
I heard that way should be CreateFile(), but what parameters to use.
for example:
My bits card has address 0x356 -a I can call _outp(0x356, nValue);
but how can I open port 0x356 with CreateFile() ??
and substitute _outp or _inp ??
Thank you for your help.
Viliam
|
|
|
|
|
If it's a serial port, you'll be able to open it with CreateFile, just look in MSDN, but if you have a custom piece of hardware or really need to access I/O ports, the way to go is creating a driver (not so hard to do as it appears).
I can't recall the name right now, but there's somewhere a driver that allows you generic access to I/O ports, but it's only a workaround, if you want a professional solution you should really create a driver for your hardware.
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|
Hello.
Provides the MFC any classes to get the current CPU usage?
) life is fun!
Johannes
//still a newbie
|
|
|
|
|
I have create a DLL,this DLL used in powerBuilder is no problem,but I used it in Visual C++ 6.0,the DLL function has finished,but a problem showed after being used DLL function,
the problem code as follow:
/////////////////////////////////////
module:
file:i386\chkesp.c
line:42
the value of ESP was not properly saved across a function call.this is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention!
/////////////////////////////////////////////////////
My DLL has a Function named int exchange(int pVar);
my code in vc is:
//declare in head file:
typedef int (*MYFUNC)(int);
//On a button clicked event code:
HINSTANCE hInstance=NULL;
MYFUNC pFunction;
hInstance=::LoadLibrary("MyDll.dll");
if(hInstance!=NULL)
MessageBox("The MyDll.DLL has already been load.");
ASSERT(hInstance);
pFunction=(MYFUNC)GetProcAddress(hInstance,"exchange");
(pFunction)(5);
ASSERT(pFunction);
::FreeLibrary( hInstance );
//when run program,show messagebox "The MyDll.DLL has already been load",and the dll function has returned right value,but then a problem appeared just as before I said?? I have trid so many ways to resolve this problem,but failed!! what this problem it is??? who can help me,thanks!!!!!!!
|
|
|
|
|
cradle wrote:
hInstance=::LoadLibrary("MyDll.dll");
if(hInstance!=NULL)
MessageBox("The MyDll.DLL has already been load.");
So you are explicitely offending yourself for being actually able to load the library. That's amusing.
Back to real work : D-19.
|
|
|
|
|
Declare the function as CALLBACK.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
How to declare CALLBACK?I never used CALLBACK,in DLL or in Project?
Can you tell me how to do?thanks!!
I m very anxious to resolve this problem!!!!
|
|
|
|