|
The handling of szTmpBuffer you show is OK. Most likely, you're overwriting the allocated space. What does the debug assertion message look like? Something about damaged blocks?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Exactly:
DAMAGE: after normal block (#3604) at (memory address)
|
|
|
|
|
Yep, I was overwriting...thanks for pointing out my stupid mistakes
|
|
|
|
|
I needed some help with resizing the size of the Static box after I have changed the font size. I want to dynamically change the size of the box so that it perfectly fits the text inside it. I wanna do this because I want the box border to fit the text inside.
i've tried :
CDC* pDC = pOrderText->GetDC();
CString text;
pOrderText->GetWindowText(text);
CSize stringSize = pDC->GetTextExtent(text);
pOrderText->SetWindowPos(NULL, 0, 0, stringSize.cx *1.45, stringSize.cy *1.45, SWP_NOMOVE|SWP_NOZORDER|SWP_NOREPOSITION);
buts the conversion is not working well. Need help asap!
A
|
|
|
|
|
Try getting the ratio of the windowsize/textsize before you change the font. Or, maybe you can use DrawText() with a flag of DT_CALCRECT to get the size of the rectangle needed by your control, then use the rect's width and height properties to set the width and height for your call to SetWindowPos()
Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store
My articles[^]
bdiamond
|
|
|
|
|
I tried this as well. But it still does not reflect the change in the font when it draws the text. Any other suggestion.?
Right now I am doing the hardcoded windowsize/textsize , but its not perfect in all the scenarios.
ali
|
|
|
|
|
I think I might have misunderstood you. Is the font size not changing at all, or is the font size changing and the window size not changing?
Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store
My articles[^]
bdiamond
|
|
|
|
|
the font size is changing but the window size is not changing accordingly.
ali
|
|
|
|
|
|
Hello All,
I'm new to coding in VC++ .NET, but have some experience writing applications in C# .NET.
I'm in the process of writing an app for which most of the code is in C++.
My question is this:
1. Can I use the Designer in my VC++ project (modifying the file Form1.h) to create the GUI?
OR
2. Do I need to follow the method suggested in the following LINK and design the GUI in a C# file and then tie it to the C++ code?
Which approach is preferable?
Thanks!
|
|
|
|
|
Is there a possibility to supress the
Loaded 'xyz.dll', no matching symbolic information found.
debugger output in VC6 (or in general=? I have a lot of deferred loading, and it'x getting in the way of my boostrap traces.
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist Fold With Us! || Agile Programming | doxygen
|
|
|
|
|
I've never found a way to suppress this. It's damn annoying!
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Is there a possibility to supress the
Loaded 'xyz.dll', no matching symbolic information found.
debugger output in VC6? I have a lot of deferred loading, and it'x getting in the way of my boostrap traces.
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist Fold With Us! || Agile Programming | doxygen
|
|
|
|
|
Hi,
I am currently working on a SDI project with CFormView as the base class. From the menu (IDR_MAINFRAME) the user can open different dialog boxes. In one of the dialog boxes I have a listbox. When the user selects an item from the listbox and click the ok button to confirm the choice and close the dialog box, I need to update a variable (int) in the CFormView derived class and also update the view, like Invalidate() method.
I have not been able to find the ansver on the web. Any code snippet or links would be highly appreciated.
Thanks in advance!
|
|
|
|
|
It's really not that difficult. If I understand what you are trying to do, it's as easy as:
int formview = dialog.listbox.getcursel();
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
Thanks for your reply!
I don't think it is that simple. Here is some more details of what I got:
SDI Project
Dialog1:
Properties - No border and style child (shown when the app starts)
CMyView is derived from CFormView
There is no controls on it!
A variable of type int m_Myint is declared
Dialog2:
Properties - Dialog frame and style popup (shown as modal when selected from the main menu)
CMyDlg is derived from CDialog
Has a button m_MyConfirmationButton and a ListBox m_MyListBox on it.
Question:
When the user clicks m_MyConfirmationButton the variable m_Myint in CMyView should be updated with the index number of the selected item in m_MyListBox.
Do I need pointers in the AppName.cpp Class where the CMyDlg DoModal() function is or???
I'm a bit lost here.
Thanks in advance!
|
|
|
|
|
Hi All,
I am using excel automation to load a .csv file and save it as an excel workbook using the following code:
COleVariant _optional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
COleVariant _false((VARIANT_BOOL)FALSE);
COleVariant _true((VARIANT_BOOL)TRUE);
COleVariant _zero(0L);
COleVariant _two(2L);
CString sFileName("TestFile.csv");
_Application app;
if(app.CreateDispatch(_T("Excel.Application")))
{
app.SetDisplayAlerts(FALSE);
app.SetVisible(FALSE);
app.SetUserControl(FALSE);
Workbooks wbs = app.GetWorkbooks();
// Load the csv into a workbook
_Workbook newWB = wbs.Open(sFileName, _zero, _false, _two, _optional, _optional, _true, _optional, _optional, _optional, _optional, _optional, _false);
newWB.SaveAs(COleVariant("TestFile.xls"), COleVariant((long)-4143), _optional, _optional, _optional, _optional, 1, _optional, _optional, _optional, _optional);
app.Quit();
app.ReleaseDispatch();
}
This code works fine and creates the Excel workbook as required. However, it leaves an instance of Excel running (visible in Task Manager). How do I ensure the instance of Excel is closed down correctly?
If I remove the wbs.Open() it runs and shuts down Excel correctly so I suspect the problem is releated to an iDispatch created during the Open() which is never released.
Any ideas?
Thanks,
Jack
|
|
|
|
|
I tried your code and it worked as expected. Excel was open for a brief moment but was quickly shut down.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Code below... cant understand why saved document is always completely empty. Any help appreciated, Thank you in advance.
hr = m_pXMLDoc->put_async(VARIANT_FALSE);<br />
if (FAILED(hr))<br />
{<br />
ErrHandler(hr); <br />
}<br />
hr = m_pXMLDoc->put_validateOnParse(VARIANT_FALSE);<br />
if (FAILED(hr))<br />
{<br />
ErrHandler(hr);<br />
}<br />
hr = m_pXMLDoc->put_resolveExternals(VARIANT_FALSE);<br />
if (FAILED(hr))<br />
{<br />
ErrHandler(hr);<br />
}<br />
<br />
...<br />
<br />
CComVariant vType(MSXML2::NODE_ELEMENT);<br />
m_pXMLDoc->createNode(vType,_T("ROOT"), _T(""), &DOMRootNodePtr);<br />
<br />
for(nRecord = nRecord; nRecord < paryData->GetSize(); nRecord++)<br />
{<br />
pRow = paryData->GetAt(nRecord);<br />
if(pRow)<br />
{<br />
if(m_straryFields.GetSize() != pRow->fields.GetSize())<br />
return -1;<br />
<br />
for(nLoop=0; nLoop < pRow->fields.GetSize(); nLoop++)<br />
{<br />
str = pRow->fields.GetAt(nLoop);<br />
str.Replace(_T(' '), _T('_'));<br />
str.Replace(_T('('), _T('_'));<br />
str.Replace(_T(')'), _T('_'));<br />
strField = m_straryFields.GetAt(nLoop);<br />
strField.Replace(_T(' '), _T('_'));<br />
strField.Replace(_T('('), _T('_'));<br />
strField.Replace(_T(')'), _T('_'));<br />
bstr = str.AllocSysString();<br />
bstrField = strField.AllocSysString();<br />
<br />
CComVariant vType(MSXML2::NODE_ELEMENT);<br />
m_pXMLDoc->createNode(vType,bstrField, _T(""), &DOMNodePtr);<br />
hr = DOMRootNodePtr->appendChild(DOMNodePtr, &DOMNodePtr);<br />
if(FAILED(hr))<br />
ErrHandler(hr);<br />
else<br />
{<br />
CComVariant vTextType(MSXML2::NODE_TEXT);<br />
hr = m_pXMLDoc->createTextNode(bstr, &DOMTextNodePtr);<br />
if(FAILED(hr))<br />
ErrHandler(hr);<br />
else<br />
{<br />
DOMNodePtr->appendChild(DOMTextNodePtr, NULL);<br />
}<br />
}<br />
}<br />
}<br />
}<br />
<br />
<br />
try<br />
{<br />
VARIANT var;<br />
VariantInit(&var);<br />
V_BSTR(&var) = SysAllocString(m_strFilename);<br />
V_VT(&var) = VT_BSTR;<br />
<br />
hr=m_pXMLDoc->save(var);<br />
<br />
if(FAILED(hr))<br />
ErrHandler(hr);<br />
hr=m_pXMLDoc->Release();<br />
<br />
}<br />
catch(...)<br />
{<br />
ASSERT(FALSE);<br />
}
I get no errors at all but the xml document that is created is always empty.
Thank you in advance,
Chris
|
|
|
|
|
You need to append the top level node to the m_pXMLDoc->documentElement.
|
|
|
|
|
Hi, I'm Javier. I'm developing an application in VC++. I want to run another application(B) inside my application(A). In this moment the application B takes control and when it's closed, then my application A retakes the control. ¿Which function or class can I use for this?
And anyone knows what's the similar to use in embedded Visual C++ for the equivalent PocketPC application?
Thank you!.
|
|
|
|
|
Lookup CreateProcess api for starting the other .exe.
Lookup WaitForSingleOnject api for 'waiting' for the .exe to end.
Chris Meech
I am Canadian. [heard in a local bar]
..a scientist venturing into the fields of philosophy and metaphysics is like Tie Domi figure skating. It's not a pretty sight. [Toronto Star Article]
|
|
|
|
|
|
|
Hello there!
I have a question regarding comboboxes in winapi.
I have added a combobox to a dialog and some items in it. (look below in the code). But now I want to get feedback on the selected item in the combobox, but I don't now how do that. Lets say that I want a messagebox to come up when I select item with index 2. How would I do that? I guess that I should to it somewhere in WM_COMMAND but how..below is some of my code.
Any help would be great!
Regards
/Peter
LRESULT CALLBACK ToolboxProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_INITDIALOG:
/*Add all the options to the combo box*/
char Buffer[64];
strcpy(Buffer,"Von Mises");
SendDlgItemMessage(hWndDlg,IDC_COMBO1,CB_INSERTSTRING,0,(LPARAM)Buffer);
strcpy(Buffer,"Principal Major Z1");
SendDlgItemMessage(hWndDlg,IDC_COMBO1,CB_INSERTSTRING,1,(LPARAM)Buffer);
strcpy(Buffer,"Principel Major Z2");
SendDlgItemMessage(hWndDlg,IDC_COMBO1,CB_INSERTSTRING,2,(LPARAM)Buffer);
strcpy(Buffer,"Principel Minor Z1");
SendDlgItemMessage(hWndDlg,IDC_COMBO1,CB_INSERTSTRING,3,(LPARAM)Buffer);
strcpy(Buffer,"Principel Minor Z2");
SendDlgItemMessage(hWndDlg,IDC_COMBO1,CB_INSERTSTRING,4,(LPARAM)Buffer);
break;
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDC_COMBO1:
{
MessageBox(hWndDlg, "Combobox selected ", "Notice",
MB_OK | MB_ICONINFORMATION);
}
break;
}
return 0;
}
break;
}
return FALSE;
}
|
|
|
|
|