|
I think that when you change the screen resolution while your program is running that you receive a WM_PAINT/WM_SIZE message from Windows.
Then you could write an WM_PAINT/WM_SIZE handler that paints the window according to the systemmetrics values.
You can probably just move the command button then to a position where it can be seen on the screen. You can use either of the functions to accomplish this.
Rundown:
-> Receive WM_PAINT/WM_SIZE
-> In WM_PAINT/WM_SIZE handler:
-> check the screenmetrics
-> call SetWindowPos / MoveWindow to place window correctly on screen
-> resize and/or move all controls on the screen
>>do i have to write the same code for all teh controls >>inside the dialog box too ???
as explained above, let the parent window handle this (dialog box)
|
|
|
|
|
Hi,
You may try using a class that simplifies resizing a dialog and all its content. There are a lot of them on CodeProject!
I wrote one, too. If you wish, look at:
CResizableDialog - A CDialog derived class to implement resizable dialogs with MFC.
I think it's quite simple to use. But there are also many other good choices. Look in the Dialog section.
Hope this helps,
Paolo.
|
|
|
|
|
One of the things you either love or hate about VS6 and VC6 is the the "member" list that appears after you've typed "->" or "." after a class or structure name.
When I add members to classes of mine, they are accordingly listed after I type the class name. However I have a header file will lots of structure definitions in a directory different to the main app / source code. If I modify one of these structures, the changes don't seem to be listed when I next type the structure name.
Any ideas why, or what I'm doing wrong please?
Thanks
|
|
|
|
|
This is a common problem, intellisense isn't really reliable in VC++ (and of course much more complicated than in e.g.VB). The advises range from waiting for full moon, step out of your cubicle and howl all night long, to: close the project, delete all temporary files (.opt, aps, .ncb, .clw, although .ncb is the likeliest), reopen the project, and open clazz wizard dialog, to rebuild the clw information. Well, I've found out both methods have their advantages... Good luck!
Peter
|
|
|
|
|
Deleting the .NCB file usually fixes it for me. The other files have nothing to do with IntelliSense. .APS = resource browser data, .OPT = debugging settings, .CLW = ClassWizard data.
|
|
|
|
|
I have an application that contains 5 buttons, when each button is pressed a pop-up menu appears with 3 choices (each menu for each button is identical but performs different tasks). Is there any way to distinguish which menu is being accessed by using any of the CMenu functions or do I have to have message handlers for each menu item based on which button was pressed.
|
|
|
|
|
I think you can use following solutions.
1. Store the number (ID,...) last pressed button
and identify menu using this information.
2. Look MSDN for Menu Messages, especially:
WM_INITMENUPOPUP,
WM_MENUCOMMAND,
WM_MENUSELECT,
WM_UNINITMENUPOPUP
They return menu handle as one of the parameters,
look also for CWnd::OnInitMenuPopup handler.
There is nothing about CMenu functions,
but may be it will help you anyway.
Igor Chouvalov
|
|
|
|
|
How can i create a virtual serial port? An excisting programm uses a serial port to retrieve data. I wont to
use a file instead of the com port. Can anyone help me?
Greetings,
Herbert Slaghekke
|
|
|
|
|
I suppose you do not control (the source) of the existing application. So you have to figure out how it talks to the COM port.
If it uses its own COM driver, you will have to emulate this driver, which can be more difficult (depending on whether you are used to writing drivers) than rewriting the existing application.
If it uses the Win32 CreateFile API call to open the COM port, you can start by either trying to specify an non-existing COM port in the program, let's say port 3. Of course if this port does not exist, the program will not be able to open it. But then again, you could create this "file" yourself and mimic the Win32 COM API mechanism. (if that works, it will be the simpliest solution).
For more information, look at the CreateFile Win32 function with regard to the COM port communications.
If the program uses Hardware flow control, it might be very difficult.
I use the following code in my programs to open a COM port. I could easily 'fool' this code that there is a virtual COM port on the other side. So it depends on the existing program's implementation.
Best regards,
GBO
---
BOOL CSerial::Open()
{
COMMTIMEOUTS timeouts;
DWORD dwSerialStatus;
char szPort[16];
char strTemp[10];
DCB dcb; // Abre el puerto serie
::ZeroMemory(szPort, 16);
::ZeroMemory(strTemp, 10);
strcpy(szPort, "COM");
_ltoa( PortNum, strTemp, 10 );
strupr( strTemp );
strcat(szPort, strTemp);
hCom = CreateFile(szPort, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);
if (hCom == NULL || hCom == INVALID_HANDLE_VALUE)
{
// try \\.\COMxx
::ZeroMemory(szPort, 16);
strcpy(szPort, "\\\\.\\COM");
strcat(szPort, strTemp);
hCom = CreateFile(szPort, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);
}
if (hCom != NULL && hCom != INVALID_HANDLE_VALUE)
{
if (GetCommState(hCom, &dcb))
{
// Llena la estructura del DCB
dcb.BaudRate = BaudRate;
dcb.ByteSize = DataBits;
switch (Parity)
{
case 'N' :
dcb.Parity = NOPARITY;
break;
case 'E' :
dcb.Parity = EVENPARITY;
break;
case 'O' :
dcb.Parity = ODDPARITY;
break;
}
dcb.StopBits = ONESTOPBIT;
if (SetCommState (hCom, &dcb))
{
if (GetCommModemStatus (hCom, &dwSerialStatus))
{
// Setea los timeouts de la puerta serie
timeouts.ReadIntervalTimeout = 100;
timeouts.ReadTotalTimeoutMultiplier = 1;
timeouts.ReadTotalTimeoutConstant = 100;
timeouts.WriteTotalTimeoutMultiplier = 1;
timeouts.WriteTotalTimeoutConstant = 100;
if (SetCommTimeouts (hCom, &timeouts))
{
if (PurgeComm(hCom, PURGE_TXCLEAR | PURGE_RXCLEAR |
PURGE_TXABORT | PURGE_RXABORT))
{
if (SetupComm (hCom, RxBufSiz, TxBufSiz))
{
if (EscapeCommFunction(hCom, SETDTR))
{
// All OK
}
else
{
DWORD dwError = ::GetLastError();
_ASSERT(NULL);
}
return TRUE;
}
}
}
}
}
}
}
DWORD dwError = ::GetLastError();
_ASSERT(NULL);
return FALSE;
}
|
|
|
|
|
Is it possible to add a bitmap to a menu without C++ class-based coding?
|
|
|
|
|
Look MSDN for SetMenuItemBitmaps function.
Igor.
|
|
|
|
|
I need to create MS Access file at runtime. I tried using CFile which is not the correct way coz it doesnt make a db file.
I'll appreciate the help.
Thanks
|
|
|
|
|
You can use:
CDaoDatabase db;
CString strDBFileName = "d:\\aaa.db";
db.Create(strDBFileName, dbLangGeneral, dbVersion30)
|
|
|
|
|
I want to change the look of minimize, maximize and close buttons in the upper right corner of dialog or window. Also I am interested in code using skins. Does enyone know some good links and info I could find on the net? Thanks in advance.
|
|
|
|
|
I don't know anything about this, but there is a recent post on code project concerning skins.
http://www.codeproject.com/dialog/skinsyse.asp
|
|
|
|
|
Does anyone know how to convert metafile to bitmap?
|
|
|
|
|
Larry,
I can't tell you from experience, but as I understand it you simply "play" the metafile into a DC and then use standard techniques to save the DC to a .bmp file.
|
|
|
|
|
Create a DIB section and a memory DC, select the DIB section into the memory DC, play the metafile into memory DC, now you got a bitmap in the DIB section.
http://www.amazon.com/exec/obidos/ASIN/0130869856
|
|
|
|
|
thanks for you both.
I am not good in graphic design. I have some code here.
I am trying to save Meta to BMP. But I only get black area.
please help.
larry
if ( OpenClipboard() )
{
HENHMETAFILE handle = (HENHMETAFILE)GetClipboardData(CF_ENHMETAFILE);
CClientDC dc(this);
CRect client(0,0,500,500);
CBitmap * bmf = new CBitmap();
CDC mdc;
mdc.CreateCompatibleDC(&dc);
bmf->CreateCompatibleBitmap(&dc,client.Width(),client.Height());
PlayEnhMetaFile(dc, handle, &client);
dc.SelectObject(bmf);
SetClipboardData(CF_BITMAP,bmf->m_hObject);
CloseClipboard();
}
|
|
|
|
|
Select bitmap into the memory DC before drawing.
|
|
|
|
|
I would like to post a message to a radio control.
The radio group consist of three radio buttons.
I would like to something like this;
myRadioControl.PostMessage(Click button 2, 0, 0);
I would appreciate a little help on the syntax.
Thanks.
pmcga61201@aol.com
|
|
|
|
|
Use CheckRadioButton(). You pass it the IDs of the first and last buttons in the group, and the ID of the button to check.
|
|
|
|
|
Hi !
I want to write a program like GameWizard in Windows (I havn't found such a program yet).
I found information to enumerate all processes but I havn't found anything to get the
adress of a process in memory (adress start and end).
Can anyone help me, please!!
TIA
Tommy
|
|
|
|
|
Each Win32 process has its own independent address space, of which only the upper part is shared system wide. For example, address 0x10000000 can point to different data in process1 vs. process2.
http://www.amazon.com/exec/obidos/ASIN/0130869856
|
|
|
|
|
I thought it was clear that I ment address space when I wrote of "address start" (base address) and "address end". I know that it's called Address Space but I think the address space MUST have
a beginning (I think this is the BASE ADDRESS of a process, which I already figured out how to get it) and I also think it should have an END because I don't think a process uses all of the
momory in a system.
Ok what I want to know is how to get the "End-Address" of the ADRESS SPACE.
By the way I'm using Win9x.
Thanks for your reply
Tommy
|
|
|
|
|