|
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.
|
|
|
|
|
why do u need to set it to Null before delete?
|
|
|
|
|
ccp999 wrote: why do u need to set it to Null before delete?
Actually, this is nonsense.
By setting a pointer to NULL you are invalidating it, not deleting the memory it points to.
Its the other way round: delete it, then set it to NULL (so that no one would use that pointer which does no longer point to memory you own again).
delete on a NULL-pointer does no harm, though.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
What is the purpose of this code?
pSNew = new string ;
pSN = (string*)_device ;
*pSNew = *pSN ;
why can't just use _device directly?
|
|
|
|
|
Without seeing the whole code it's hard to say, but what it is doing is making a copy of the variable.
You have to set the pointer to null otherwise delete will throw an exception.
|
|
|
|
|
I'm afraid that you can not delete the string because the PostMessage method posts the message and immediately returns. Note SendMessage sends the message and waits until it is processed. So if you delete the string the method which will process the message (sent via PostMessage) will probably crash because the pointer is invalid. Therefor the message processing should delete the string.
Moreover if this message is posted to different application it is even complicated. In that case I recommend to use GlobalAddAtom and GlobalDeleteAtom. But probably this is not your case...
|
|
|
|