|
//Win 32 Application
//Hello world program
CALLBACK Winproc(HWND,Message,wParam,lParam)
Switch(wId)
...
....
case WM_MOUSE:
if(condition)
{
HWND hCursor=LoadCusor(hInst,(LPSTR)IDI_NEWCURSOR);
SetCurspr(hCursor);
else
.......
When condition ==1 ,the cursor not change.
Help me.
all for development e
|
|
|
|
|
I want to help you but what question?
|
|
|
|
|
Handle WM_SETCURSOR and if the cursor is within that rect, call SetCursor() to change it.
|
|
|
|
|
I've conclued I don't really know how to get handles to objects in VC++. They are referred to all the time, and I get the idea they are one of the basic tools of VC++ along with pointers. The books and manuals all talk about handles, but presume the reader is bright enough to know how they all work. I'm not. (Someone who knows what they are doing could write a great article titled, "Handles for Beginners")
So.....
Suppose I have:
dialog: CTestDlg
edit control: IDC_EDIT1
member function: CTestDlg::FuncTest
Exactly how would one get handles to any or all of these? I suspect one starts with
"HWND hHandle = ???????"
But what goes on the right side of the expression?
Thanks.
|
|
|
|
|
Handles are a Windows concept - they are just used in VC because VC normally is used for Windows programming. They are similar to a pointer in that they store an index into some internal table. By looking up that index, Windows can find the actual data that manages the window. But as far as you are concerned, a handle is just some opaque number you can pass around to various Windows functions.
For the dialog - there should be something like pTestDlg->getHwnd() or whatever the MFC equivalent is.
To get a handle to a control, call ::GetDlgItem(hDialog, IDC_EDIT1); where hDialog is an HWND obtained by using a method above. Alternatively, if IDC_EDIT1 is represented by an MFC class, just call the getHwnd equivalent on that class.
Member functions cannot have handles. A handle is used by Windows - but a member function is just a special type of function. You can create a pointer to a member function, but the syntax is ugly and very limited as to what you can do. Or you can search for fastdelegate on CodeProject to find a member function pointer wrapper.
Mike
|
|
|
|
|
Hi,
I dont know what exactly do you need by I am suspecting you want to get a HANDLE to the IDC_EDIT control. If this is the case,
You can use the following
CWND* pwnd=this->GetDlgItem(IDC_EDIT1);
it will return a pointer to that EDIT CONTROL. But this is CWND pointer; if you need the HWND then
CWND has a member variable m_hwnd which is public.
So
HWND handle=pwnd->m_hwnd;
But I guess, if you are using MFC, the pwnd is enough to do something to the window like writing a text, for example.
pwnd->SetWindowText("Text");
Regards,
Angbo2006
|
|
|
|
|
|
Thanks for the help. I didn't have an immediate and particular need, but I simply recognized a deficiency in my understanding of how to get a handle. So, I try to formulate a tight question that will shed some light. When I see correct code that does something, and understand its intent, then I can backtrack through the manuals and get a full understanding. (I guess that is my learning style.) I found the four volume MFC reference library in a used book store for $2 each, and have been reading about all these great classes and functions. However, the difficulty arises in understanding exactly how to write the code to get the required arguments for the functions.
Thanks again
|
|
|
|
|
Could somebody please point me towards the correct set of functions to create a full screen window. I have a window ( 800 x 600 ) which I need to view in full screen, but I will need to change the screen resolution in order to this. All the articles I have found so far simply resize the window and remove the titlebar. This is not the effect I want. I should also note this has to be done without MFC or ActiveX.
|
|
|
|
|
Can you explain I guess your question isnt for a change simple size
|
|
|
|
|
The window has a bitmap skin, so really resizing isn't an option. In order for the window to become full screen I will also need to change the resolution to match that of the bitmap. I have seen this done with lots of games, so I know it's possible, I just don't know how.
|
|
|
|
|
In the CreateWindow function, the third parameter is the window sytle, change it to:
WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE
Like this (in WIN32):
<br />
wndHandle = CreateWindow (<br />
TEXT("Full screen"), <br />
TEXT("Full Screen"), <br />
WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE,<br />
CW_USEDEFAULT, <br />
CW_USEDEFAULT, <br />
1280, <br />
1024,<br />
NULL, <br />
NULL, <br />
hInstance, <br />
NULL );<br />
Hope that helps.
|
|
|
|
|
That will allow me to place the window over the Task bar, but I still need to change the resolution of the screen, and be able to restore it later. I'm currently searching for an easy way to do this.
|
|
|
|
|
You are writing a game, aren't you? I know what you want to do, you need to write your own Graphics manager to do initalize all this little details.
|
|
|
|
|
haha. Yes it is a game, but this window is only a small part of the game which will be contained within a dll. The main game window will have full use of the graphics system, but fr this little window there is no point.
|
|
|
|
|
Hi,
You need to call ChangeDisplaySettings as below
DEVMODE devm;
devm.dmSize=sizeof(DEVMODE);
devm.dmPelsWidth=NewPelsWidth;
devm.dmPelsHeight=NewPelsHeight;
devm.dmFields=DM_PELSHEIGHT|DM_PELSWIDTH;//|DM_BITSPERPEL;
UINT b=ChangeDisplaySettings(&devm,0);
//test b for success
Regards,
Angbo2006
|
|
|
|
|
int iX = GetSystemMetrics(SM_CXSCREEN);
int iY = GetSystemMetrics(SM_CYSCREEN);
DEVMODE dm;
dm.dmSize = sizeof (DEVMODE);
dm.dmPelsWidth = iX ;
dm.dmPelsHeight= iY ;
dm.dmBitsPerPel= 32 ;
dm.dmDisplayFrequency = 75 ;
dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT |
DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
ChangeDisplaySettings(&dm,CDS_FULLSCREEN);
MoveWindow(0,0,iX,iY);
|
|
|
|
|
Hello everybody
I would appreciate it if I can get help adding a picture into my program. I'm using visual c++ 6. This must really be simple, I just need the picture on my main dialog, but the program should be able to run without having the bitmap with it.
thanx...
KOM UIT DAAAAA!!!
|
|
|
|
|
You can import bmp file to resource and use of CBitmap::LoadBitmap for load use of WM_PAINT or WM_ERASEBKGND for draw it,but my suggestion is you reading your file from disk instead import it to your project because it increase size of your exe
|
|
|
|
|
How should i add the bitmap to the resources? The size of the exe isn't a issue in this case, thanx for the help....
KOM UIT DAAAAA!!!
|
|
|
|
|
Right click on resource window and select Add Resource and click import button and select your file and click open button now this file insert to resources now you can use from this code in your program
<br />
CBitmap p;<br />
p.LoadBitmap(IDB_BITMAP1);<br />
and then on WM_PAINT try to draw it
Resource Window->Add Resource->Import->Select File->click open
--------------------
But if you have a picture on clipboard and you want to insert it to resource you can create a bitmap on resource and if Color file is True Color then select True Color on resource and then use of Shift+Insert now this picture paste on resource
|
|
|
|
|
I have somewhat of a strange problem. I have designed a custom window in which the title bar is inside the window as opposed to on top. I process all the mouse messages to correctly handle clicks and whatnot within this new area. The problem relates to the WM_NCLBUTTONUP message. I added this to handle the button clicks, but it is never trapped, infact when a button is double clicked the WM_NCLBUTTONUP works. WM_NCLBUTTONDOWN works as it should, but to process button clicks this is in appropriate. Also the WM_NCLBUTTONDBLCLK works as should. Can anybody think of a reason why my WM_NCLBUTTONUP handler only responds to double clicks?
case WM_NCHITTEST:
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
ScreenToClient(hWnd,&pt);
SetRect(&rc,RECT_NONCLIENT);
if ( PtInRect(&rc,pt) )
{
SetRect(&rc,RECT_CLOSE);
if ( PtInRect(&rc,pt) )
return HTCLOSE;
return HTCAPTION;
}
return HTNOWHERE;
case WM_NCLBUTTONUP:
switch ( wParam )
{
case HTCLOSE:
SendMessage(hWnd,WM_CLOSE,0,0);
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
|
Never mind, my own stupid fault. I hadn't included a WM_NCLBUTTONDOWN handler to prevent DefWindowProc from messing thing up.
|
|
|
|
|
My colleague wrote the following code and I wander why there are no "delete" statement for the two string variables *pSNew and *pSN.
Is there a memory leak?
Urgent! Thanks
void CCommTSP32View::OnPMDeviceFound( long _id, long _device )
{
// now it critical!
EnterCriticalSection( &m_csCommunicationSync ) ;
string *pSNew ;
string *pSN ;
// Init
pSNew = new string ;
pSN = (string*)_device ;
*pSNew = *pSN ;
PostMessage( WM_SPY_DEVICE_FOUND, _id, (long)pSNew ) ;
// release critical section
LeaveCriticalSection( &m_csCommunicationSync ) ;
}
ccp
|
|
|
|
|
string *pSNew should really be deleted after the call to PostMessage, but since the pointer is being passed to another part of the code, it's possible it is being deleted there. Take a look at the WM_SPY_DEVICE_FOUND handler to verify what is happening to the lParam.
Generaly, it's bad practice to allocate and deallocate memory in seperate parts of the code. As a rule, any time I delete something, I will set it to NULL, then, at the same place of allocation, I will try to delete again if no longer required.
|
|
|
|