|
what property does CStatic contains that can be usefull for a CDialog ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Dear friendz....
i would like to know how i can change the color of the frame of a picture control placed on a dialog box when a certain event(say onmousemove())takes place??
all suggestionz are welcome.....
thanx in advance...
|
|
|
|
|
plz help!!!!!
HICON hIcon = AfxGetApp()->LoadCursor( IDC_CURSOR1 );
SetCursor( hIcon );
return TRUE;
is a working code coz i have put this in my Dialog based application (Xyz) in a class called CXyzDlg..... that is, i have already added this function "OnSetCursor()".....and the cursor changes......in the main Dlg box but..... i have derived a class from the CStatic Class named it as "CMyClass".....and i have created obcts of it in the CXyzDlg class.....basically these objects i have created by placing the "static control" on the dialog box and then..... thru the class wizard created an object linking it with the picture control of type CMyClass(that is .....SUBCLASSING).....
also in thiz CMyClass i have added the "OnSetCursor()" function as well......and many other mouse functions like "onmousemove()","LbuttonDown()".....etc.....but here when i put in the same code as i had put in the main Dlg box for the "OnsetCursor()".....it does not change!!!!!......y???
heres the code......that i have put in the derived class CMyClass......
#include "stdafx.h"
#include "creamz.h"
#include "MyClass.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CMyClass::CMyClass()
{
m_DragOn1=FALSE;
m_pot1=0;
m_update=TRUE;
}
CMyClass::~CMyClass()
{
}
BEGIN_MESSAGE_MAP(CMyClass, CStatic)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_SETCURSOR()
END_MESSAGE_MAP()
void CMyClass::OnLButtonDown(UINT nFlags, CPoint point)
{
HICON hIcon = AfxGetApp()->LoadCursor( IDC_CURSOR2 );
SetCursor( hIcon );
m_DragOn1=TRUE;
CStatic::OnLButtonDown(nFlags, point);
}
void CMyClass::OnLButtonUp(UINT nFlags, CPoint point)
{
HICON hIcon = AfxGetApp()->LoadCursor( IDC_CURSOR1 );
SetCursor( hIcon );
m_DragOn1=FALSE;
CStatic::OnLButtonUp(nFlags, point);
}
void CMyClass::onmousemove(UINT nFlags, CPoint point)
{
if(m_DragOn1==TRUE)
{
if(m_pot1<62)
m_pot1+=1;
else
m_pot1=0;
if(m_pot1%2==0)
m_update=TRUE;
}
CStatic::onmousemove(nFlags, point);
}
BOOL CMyClass::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if(m_DragOn1==FALSE)
{
HICON hIcon = AfxGetApp()->LoadCursor( IDC_CURSOR1 );
SetCursor( hIcon );
}
else
{
HICON hIcon = AfxGetApp()->LoadCursor( IDC_CURSOR2 );
SetCursor( hIcon );
}
return TRUE;
}
plz help me out......
thanx in advance.....and thanx for ur intrest!!!!!
|
|
|
|
|
I think your problem maybe use of local variable that goes out of scope immediately after your call to SetCursor.
I suggest making a member variable for your class:
HICON m_CursorIcon;
In your constructor, set it to NULL:
m_CursorIcon = (HICON)0;
Add a new member function you call anytime you want to change the cursor:
void MySetCursor(UINT idCursor){<br />
m_CursorIcon = AfxGetApp()->LoadCursor( idCursor );<br />
if( !m_CursorIcon ){<br />
return;<br />
}<br />
SetCursor( m_CursorIcon );<br />
}
|
|
|
|
|
thanx for the reply.....but that too doesnt work..... .....i dont think m_cursorIcon being a local variable is a prob actually coz i had put in a code to trace if the control was going to the OnSetCursor() and it does.....only thing is that the mouse pointer doesnt get updated......
any ideas???
thanx a lot for ur reply.....
|
|
|
|
|
Here is an idea, from the MSDN:
If your application must set the cursor while it is in a window, make sure the class cursor for the specified window's class is set to NULL. If the class cursor is not NULL, the system restores the class cursor each time the mouse is moved.
|
|
|
|
|
can u elaborate a little more please!!!!!.....what am i to make NULL??is it the OnSetCursor
|
|
|
|
|
It involves checking and possibly changing the HCURSOR field of the WNDCLASS associated with your CStatic window. However, in the context of MFC, this can get you into trouble really quick, since you would be changing it for EVERY CStatic in the program - and every window using the class registered (which cna be other types, knowing hwo MFC seems ot work...).
As a different approach, why don't you look at Chris' CHyperLink control on this website. Study his code, because, as I recall, it changes the cursor to a pointy hand when the mouse is over the window. Using his code as an exmaple, you should be able to see how to get the cursor changed in your window. I think his is even derived from CStatic.
http://www.codeproject.com/miscctrl/hyperlink.asp
|
|
|
|
|
Is there a minimum size when allocating memory using CoTaskMemAlloc() ?
For ex;
LPBITMAPINFO pDibImage = NULL;
pDibImage = (LPBITMAPINFO)CoTaskMemAlloc(400);
once I do this, the BIMAPINFO fileds such as bmiHeader and bmiColor values
are not set to 0. They are filled with Garabage...
Why ?
but if I assign a larger memory block like..
pDibImage = (LPBITMAPINFO)CoTaskMemAlloc(6606760);
Then everything is initlized properly....
any ideas? thoughts?
Thanks
|
|
|
|
|
I suppose, because the MSDN DOCUMENTATION has this to say...
The initial contents of the returned memory block are undefined – there is no guarantee that the block has been initialized.
So, if you want the memoryto be all ZEROed out, you must do it yourelf, thusly:
pDibImage = (LPBITMAPINFO)CoTaskMemAlloc(400);
if( pDibImage ){
ZeroMemory(pDibImage, 400);
}
You just randomly drew some 'zeroes' when you allocated the larger block.
The minimum size is 0:
If cb is zero, CoTaskMemAlloc allocates a zero-length item and returns a valid pointer to that item. If there is insufficient memory available, CoTaskMemAlloc returns NULL.
Also...
Note Applications should always check the return value from this method, even when requesting small amounts of memory, because there is no guarantee the memory will be allocated.
|
|
|
|
|
I'm attempting to write an MFC based program that uses Arabic fonts for an Arabic class I'm taking. I'm using WinXP and have the fonts installed (i.e. I can type in Arabic in MS word), but I can't seem to associate one of those fonts with a CFont object. Well I can, but it seems that text still comes out in English. I set the justification mode from right to left and specified the enumerated type ARABIC_CHARSET when initializing the CFont. Here is a sample of the display callback in my code where I'm simply just outputting the string "hahah". It shoudl come out in
Arabic (the letters "sheen" and "alif"). Any ideas? Do I need to link to some DLL? Does some sort of preprocessor definition have to be declared? Oh and I'm using visual c++ 6.0.
void CFACKDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPaintDC dc(this);
dc.SetTextColor(RGB(0,0,0));
dc.SetTextAlign(TA_RTLREADING);
fntArab.CreateFont(rcClient.Height()/20, 0, 0, 0,
FW_DONTCARE, FALSE, FALSE, 0, ARABIC_CHARSET,
OUT_TT_PRECIS, CLIP_LH_ANGLES,
DEFAULT_QUALITY, FF_DONTCARE, "arabic transparent bold" );
dc.SelectObject(&fntArab);
dc.TextOut(30,90, (CString)"hahah");
CDialog::OnPaint();
}
}
M.A. Shah
Computer Science Student - Penn State University
|
|
|
|
|
I thought I might have to do something like that, but I was trying to avoid it . Thanks for your help.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Is there any algorithm who find a double character in a string as for example (two spacebars,two semicolons )and delete one of them?Please tell me where can I find this algorithm...Thank you
|
|
|
|
|
Have you looked at CString::Replace() ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
hi,
I want to add Custom Explorer Bar to Internet Explorer using C++.Can any body tell me how am I going to do that?
Thanks in advance..
|
|
|
|
|
pubududilena wrote:
I want to add Custom Explorer Bar to Internet Explorer using C++.Can any body tell me how am I going to do that?
Please Look at MFC/C++-->InTernet Section, you will found tons of example implementing that
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
When i import both libraries in Pocket PC project i get some redefinition errors:
<br />
error C2011: '_Collection' : 'struct' type redefinition<br />
error C2011: 'DataTypeEnum' : 'enum' type redefinition<br />
error C2011: 'Properties' : 'struct' type redefinition<br />
error C2011: 'Property' : 'struct' type redefinition<br />
how can be used both of them and avoid conflicts?
were rgrtgrtvrtrt rtrtb brt tyuhjghj hbhbnh hnjm 1234567?
|
|
|
|
|
Why do you need to import both libraries?
Surely adoxce31.dll extends adoce31.dll and therefore you do not need to import adoce31.dll!?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
I had the same issue, but with the PC implementation.
You will need to import the ADOX structures first, then import the ADO object, but with a redefinition.
#import "C:\Program Files\Common Files\system\ado\msadox.dll"
#import "C:\Program Files\Common Files\System\ado\msado15.dll" rename ("EOF","ADOEOF")
You could probably use the same method for your Pocket PC objects.
I Dream of Absolute Zero
|
|
|
|
|
Hi,
I have an MDI application which has a Splitter Window. The left-hand side is a TreeView and the right-hand side is a CFormView. Initially the CFormView is associated with an empty dialog, say IDD_DIALOG1. Now during runtime I have created an array of Dialog Templates in memory and added controls to them. All dynamic. Now once the user selects some option under the TreeView Control, I need to display the newly created dialog templates on the right hand side. How do I do this? I have been able to destory the exisiting window of the formView but How do i associate it with this new template and display it???
|
|
|
|
|
hi there .....;)
how do i put a bmp that is present a particular location in the hardisk into an exe when building the exe file??
|
|
|
|
|
Include it as a resource.
-------------------------
Have a great day ahead!
Regards,
Sohail Kadiwala
(My COM Blog - http://lovecom.blogspot.com)
modified 21-Apr-21 21:01pm.
|
|
|
|
|
|
Yeah i Elobarate on behalf Of Mr Sohail.
Follow these Steps
1. Insert| Resource or ctrl+r to open Resource Dialog
2.Press Import to import that bmp to your Project.
i think you are familiar with rest
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
no......thatz something that i had already tried out!!!!!
u c the bitmap happenz to be 24 bit type.....so it does not get loaded(even if it does it gets converted to 256color(16 bit).....
right now i load the image seperately.....tahtz the only way i am able to get it as 24 bit
any ideas??
|
|
|
|