|
I created a CMFCToolBarComboBoxButton in a CMFCToolBar as following:
afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM wp, LPARAM lp)
{
UINT uiToolBarId = (UINT) wp;
if (uiToolBarId == IDR_TOOLBAR_FILES)
{
CMFCToolBarComboBoxButton omboButton1(IDC_SRC_PRO_LIST, GetCmdMgr ()->GetCmdImage(IDC_SRC_PRO_LIST, FALSE), CBS_DROPDOWNLIST);
comboButton1.EnableWindow(FALSE);
comboButton1.SetCenterVert();
comboButton1.SetDropDownHeight(200);
comboButton1.SetFlatMode();
m_wndFilesBar.ReplaceButton (IDC_SRC_PRO_LIST, comboButton1);
}
}
It runs well.
But when I want to add some content into it from another thread.I defined a function:
int CMainFrame::CBAddItem(LPCTSTR lpszItem, DWORD_PTR dwData)
{
int r = -1;
CMFCToolBarComboBoxButton* pSrcCombo = CMFCToolBarComboBoxButton::GetByCmd (IDC_SRC_PRO_LIST);
if(pSrcCombo)
{
r = pSrcCombo->AddItem(lpszItem, dwData);
}
return r;
}
The function CMFCToolBarComboBoxButton::GetByCmd always return NULL. And I traced this function, found:
int __stdcall CMFCToolBar::GetCommandButtons(UINT uiCmd, CObList& listButtons)
{
.....
for (POSITION posTlb = afxAllToolBars.GetHeadPosition(); posTlb != NULL;)
{
CMFCToolBar* pToolBar = (CMFCToolBar*) afxAllToolBars.GetNext(posTlb);
ENSURE(pToolBar != NULL);
if (CWnd::FromHandlePermanent(pToolBar->m_hWnd) != NULL)
CWnd::FromHandlePermanent(pToolBar->m_hWnd) always return NULL.
So why?
|
|
|
|
|
Check if you met the requirements described at the MSDN page Multithreading: Programming Tips[^].
A common solution to access MFC objects from other threads is posting user defined messages. Then the manipulation of the object occurs inside the thread that owns the MFC object. If your thread is a worker thread see the CP article Using Worker Threads[^] for examples.
|
|
|
|
|
I have this code
BOOL CFormOptions::OnPreparePrinting(CPrintInfo* pInfo)
{
tagPDA pPrintDlg;
AfxGetApp()->GetPrinterDeviceDefaults (&pPrintDlg);
pInfo->m_pPD->m_pd.hDevMode = pPrintDlg.hDevMode;
LPDEVMODE devMode = pInfo->m_pPD->GetDevMode();
if (devMode)
{
if (m_legal)
devMode->dmPaperSize = 45; else
devMode->dmPaperSize = DMPAPER_LEGAL;
devMode->dmPaperWidth = 2000;
GlobalUnlock(devMode);
}
if ( pInfo->m_bPreview ) return DoPreparePrinting(pInfo);
return DoPreparePrinting(pInfo);
}
and I can adjust the paper size from letter to legal. But if I try to adjust the paper size to DMPAPER_10X11 or any other size, the software ignores it and just uses letter size.
How can I adjust the paper size to be something like DMPAPER_10X11? I tried adjust the PaperWidth as well and that is ignored as well. So Im not sure what Im doing wrong.
Any help, any direction any one can provide will be greatly appreciated.
|
|
|
|
|
I think you might need to tell the devMode which fields are being initialized by setting the dmFields member
example of setting landscape orientation:
devMode->dmOrientation = DMORIENT_LANDSCAPE;
devMode->dmFields |= DM_ORIENTATION;
|
|
|
|
|
Howdy!
With the new great OS -- 10 -- we're seeing something odd.
Running our installer is not shutting down our app.
We do receive the WM_QUERY_ENDSESSION and we do reply with TRUE ( ok to shutdown )
But, upon receiving the WM_ENDSESSION we receive a FALSE (don't shutdown).
Somewhere between the QUERY and the END -- "someone" is saying NO to this.
How does one go about debugging this sort of thing?
I've used SPY++ but am not finding it to be the most useful tool, except to confirm what I knew in code. SPY is not telling me who sends the QUERY. If I could figure out where these messages are coming from, maybe I could watch the conversations taking place around this transaction.
-- in previous versions of Windows this was not an issue -- it worked like we would expect. But Windows10 is telling me not to end my session.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">soonr.com -- PC Power delivered to your phone</a>
|
|
|
|
|
hi i had learn c++ and something about the framework Qt but the problem that the Qt is not used for building apps smartphone like C# or JAVA !!
so do u advice me to leave c++ and Qt and start with C# or JAVA ??
please i need your Advice Thank you
![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Pick one place and post there, not in QA, C++, and C#.
Otherwise, you duplicate work and annoy people.
You have this posted in QA, so leave it there.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
pick whatever provide you job! beggar are not chooser
|
|
|
|
|
Hi Friends,
I am trying to set focus on the first button in a toolbar control if a key combination like ALT + SHIFT + A is pressed. I am using preTranslate Message, like this
if ( pMsg->message == WM_SYSCHAR && (GetKeyState(VK_SHIFT) & 0x8000) && (pMsg->wParam == 'a' || pMsg->wParam == 'A') )
{
m_wndToolBar.SetFocus();
}
Now. I am getting focus on first button of toolbar. I clicked SPACEBAR and this button get pressed. It open a dialog , after my operation I closed it.
After that, Unfortunately second button get activated. I pressed spacebar again.It will pressed that button and called related function , which will open another dialog. After my operation, I closed it .
Now the focus went to First button. According to project requirement the focus must retain to the last clicked button. I checked in project code, nowhere first button getting activated explicitly.
Please help me out.
Regasrd,
Amrit Agrawal
|
|
|
|
|
I am working on a legacy Windows app written in Win32.
There's a checkbox in the screen and i call the SetFocus() function to have the focus on it. I know that it works as far as setting the focus, because now i can use space button in keyboard to check and uncheck the checkbox.
But the problem is, when a control get's the focus, it's supposed show a broken rectangle around it. In my case this broken rectangle is not drawn/shown all the time. Sometimes it shows the broken rectangle and some times it doesn't.
I need to show some visual indication to user that this checkbox has the focus. I tried using WM_CTLCOLORSTATIC, but that creates some painting issues in the window.
So am looking for a simpler solution, by which i could show some visual indicator to user that this checkbox is having focus.
Like changing the text color or background color or even force draw a broken rectangle.
But i have no idea how to do this without using the WM_CTLCOLORSTATIC.
Is there a easier way to show some sort of visual indication on a checkbox in Win32?
Thanks in advance!
|
|
|
|
|
I don't know exactly, but it seems to me that you should never call SetFocus() method. Instead, we have to post WM_SETFOCUS message to the checkbox control as follows:
HWND hCheckBoxWnd = NULL;
if ((hCheckBoxWnd = ::GetDlgItem(hDlg,IDC_YOUR_CHECK_BOX_ID)))
::PostMessage(hCheckBoxWnd, WM_SETFOCUS, 0, 0);
Actually, you should not send the message using SendMessage(...) Win32API function, all you have to do is to post the message using PostMessage(...) instead.
|
|
|
|
|
I have 10+ years experience with C#. I now have an opportunity learn C++.
I'd like to work in Visual Studio (2012 and higher).
Can someone recommend a decent starter book or web reference?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
There's a bunch of good texts listed in this[^] thread.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
|
My app was running fine with Windows 7 & 8.1 using URLDownloadTofile(NULL,sUrl,SFile,0,NULL). With the upgrade to Windows 10 it has stopped working. I've made sure my app has security settings to allow it through the firewall (and this hasn't changed) but now the request to download fails. Also the Visual Studio 2008 Document explorer now just comes up with "Unable to download <help page="">" which makes me suspect it's a more general problem that just my app. I can't find any security settings that should be blocking my app.
If any one could shed some light on my problem I'd be grateful. I've trawled around the web for a day with no useful results.
Thanks,
David.
|
|
|
|
|
Have you tried running Visual Studio as administrator?
What is the error that you are getting?
|
|
|
|
|
Thanks it turned out the problem was that the directory that the Temporary Internet files were stored in no longer existed after the update to Windows 10. Trying to change this under the Control Panel application for Internet settings failed to change the directory as the one that it was trying to move the files from did not exist. The only way to correct the problem was to manually edit the registry key as explained here:
https://msdn.microsoft.com/en-us/library/ms940828(v=winembedded.5).aspx
|
|
|
|
|
Hi,
I want to read an xml file in C++. Is there any sample code or any library available.?
I want to read the contents of XML file. Its nodes and attribute's value.
I need an XML parser written in C++.
Any help will be appreciated.
Regards,
Mbatra
modified 12-Aug-15 6:17am.
|
|
|
|
|
Oh I doubt it. I dont think anyone's ever used c++ to read xml files, let alone written a library for it. Google will surely vindicate me..
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
See if this will get you started.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
MSXML and tinyXML are two options for you.
|
|
|
|
|
I use Expat to read XML files. See http://www.libexpat.org/.
I use to this to read Excel XLSX files once they are unzipped with the zlib library.
|
|
|
|
|
We build our own library on top of MSXML (painful).
Now, I'm trying to push http://pugixml.org/[^] for our XML need; I've used it for relatively small and not too complex XML files and it works great.
I'd rather be phishing!
|
|
|
|