|
You have to be careful - that lfWidth for example, is only for an average character. A line of iiiii's will be shorter than the same amount of wwwww's.
Have a look at GetTextExtent, as that will tell you exactly how manu pixels you need for a given font / string.
Also, the PathCompactPath function may help you if the text you're trying to fit in one line is a file path (or can be treated similarly)
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hello All,
Iam using CTreeCtrl method to add items in a tree.Actually i create two root nodes using GetRootNode()method.I add both root nodes properly in the tree,But what's my problem is i need to add child nodes in appropriate parent(root)nodes at runtime.But,all the child nodes adding in the first parent(root)node only.once i use deleteallitems() and redraw the tree only child nodes are added in appropriate parent(root)nodes.Without using DeleteAllItems() i need to add the child nodes in a appropriate parent(root)node.
please anybody help me.
Thanks in advance,
Regards,
bhanu.
|
|
|
|
|
|
Iain Clarke wrote: I apologise...
You don't need to [^]
Regards,
Sandip.
|
|
|
|
|
Hi,
I have a combo box in a dialog.This combo box data is populated from registry as soon as dialog opens. I need to change this dialog now. When I tried to change the dialog,combo box is populating with some junk characters(not readable). Even a small change in the dialog, like resizing the dialog, resulted in junk charaacter in a combo box.
Any idea why it is happening? any project settings change required?
Thanks in advance..
|
|
|
|
|
Probably you've to post some code (and be more precise about what is happening) to get help.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
check your project settings for unicode compilation.
Greetings,
Ralph
|
|
|
|
|
Hi there,
I have created a thread that just monitors the serial port, but as soon as the com port receives any data, the GetOverlappedResult issues an ERROR_OPERATION_ABORTED error.
Please can you take a look at my code, I cannot see what is going on.
Thanks
Jim
#define READ_TIMEOUT 500 // Milliseconds
UINT CPageOneDialog::monitorPTZThread(LPVOID pParam)
{
DWORD dwRead, dwRes;
BOOL fWaitingOnRead = FALSE;
OVERLAPPED osReader = {0};
char ptzControlCommPort[14];
struct PTZCommStruct *pPTZStruct = (struct PTZCommStruct *)pParam;
sprintf(ptzControlCommPort,"\\\\.\\COM%d",PTZCTRLPORT+1);
pPTZStruct->hPTZSerial = CreateFile( ptzControlCommPort,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL
);
osReader.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if(osReader.hEvent == NULL)
{
pPTZStruct->pWnd->PostMessage(UWM_READER_SHUTTING_DOWN);
return 0;
}
while(pPTZStruct->nPTZCommTerminate == 0)
{
if(!fWaitingOnRead)
{
if(!ReadFile(pPTZStruct->hPTZSerial,PTZbuffer, MAX_BUFFER_SIZE, &dwRead, &osReader))
{
if(GetLastError() != ERROR_IO_PENDING)
{
return 0;
}
else
{
fWaitingOnRead = TRUE;
}
}
else
{
}
}
else
{
dwRes = WaitForSingleObject(osReader.hEvent, READ_TIMEOUT);
switch(dwRes)
{
case WAIT_OBJECT_0:
if(!GetOverlappedResult(pPTZStruct->hPTZSerial, &osReader, &dwRead, FALSE))
{
DWORD dwError = GetLastError();
switch(dwError)
{
case ERROR_HANDLE_EOF:
return 0;
break;
case ERROR_IO_PENDING:
return 0;
break;
case ERROR_IO_INCOMPLETE:
return 0;
break;
case ERROR_OPERATION_ABORTED:
return 0;
break;
default:
Dump1("Serial Read Error %d\r\n", ::GetLastError());
return 0;
break;
}
}
else
{
}
fWaitingOnRead = FALSE;
break;
case WAIT_TIMEOUT:
break;
default:
return 0;
break;
}
}
}
return 0;
}
|
|
|
|
|
Hi all,
Is there anyway to have bold text of the message displayed using
AfxMessageBox().
If yes please give me the solution.
Regards,
Sunil Kumar
|
|
|
|
|
Try this lInk [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Ok I understood.we cant do it...
Regards,
Sunil Kumar
|
|
|
|
|
I believe CPallini is right with it, but you could maybe try handing WM_CTLCOLORDLG[^] and try to select a bold font into the DC you get as parameter, no idea if it would work or not, but maybe it is worth a try.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
You can make your own messagebox.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Yeah ,its an option....
Regards,
Sunil Kumar
|
|
|
|
|
The answer to your question is a simple No.
But you can a) roll your own messagebox-a-like, and there are plenty in the dialogs section of codeproject.
or b) if you're on vista, use a Task Dialog (see http://blogs.chimpswithkeyboards.com/jonshute/archive/2006/11/26/230.aspx[^] for an article about it)
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
I am upgrading my VC6 app to new mfc feature pack, I have to add a CMFCMenuBar on a dialog box, I am able to add and display the menu bar, but none of its pop up menu items work.... All the menu items in dropdwn/popup menu in menu bar are disabled and not responding to any message... after adding message handler functions, anybody has any idea?? I am posting my code to create and display menubar (CMFCMenuBar) on a dialog box here. I have tried to put this code within OnInitDialog() as well as OnCreate() function of the dialog class.
m_wndMenuBar is a CMFCMenuBar object decleraed in .h file.
if (!m_wndMenuBar.Create(this))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
CMenu *menu = new CMenu();
menu -> LoadMenu (IDR_ITEM_MENU);
m_wndMenuBar.CreateFromMenu(menu->GetSafeHmenu(),TRUE,TRUE);
m_wndMenuBar.SetDefaultMenuResId(IDR_ITEM_MENU);
m_wndMenuBar.SetWindowPos(NULL,0, 0 ,500,30,SWP_SHOWWINDOW);
Never complain,never explain,just do your work.
|
|
|
|
|
I have the same problem.Have you solved it?
|
|
|
|
|
Hi all,
when we press key Window+D than desktp is displayed.
i mean Window+D use for show desktop,here all opened applications are minimized.
how can chk wnd+D press.
please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
You handle it by letting windows do the work.
You wouldn't think you know more about a user's needs than they do, would you?
----
OK, If you're running some sort of kiosk application, I can see how you might want to do something about it. But in that case, I think you can disable a lot of this stuff from within control panel / policies. (gpedit.msc from memory)
----
Just imagine if any program could say "sod you, I'm going to override the user's preferences and stay up all the time. Nerr". To misquote myself, do you think EvilProgram(tm).exe will say "no, I won't leave my 'buy personal enhancement drugs' advertisement on the screen... that would be rude"...
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Iain Clarke wrote: EvilProgram(tm).exe
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Well, it would be dishonest of them to call it ImAGoodProgramHonestIAm.exe.
That would shock my trust in humanity!
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Capture WM_KEYDOWN msg in PreTranslateMessage use Virtual Key Code to determine the required combination.
Check this.
BOOL CDlg::PreTranslateMessage(MSG* pMsg)
{
switch(pMsg->message)
{
case WM_KEYDOWN:
{
if( (GetKeyState(VK_LWIN)||GetKeyState(VK_RWIN)) &&
(pMsg->wParam == 0x44)
)
{
}
}
}
}
|
|
|
|
|
Its not working.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
What exactly is failing?
It should work coz I too have used this technique in my code so many times.
|
|
|
|
|
PreTranslateMessage(MSG* pMsg) function calls when Wnd key pressed its not handel both keys together thats why its not working.
please tell me solution for this.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|