|
Brad Sokol:
Your solution is good! Thanks very much!
Now I can do it well.
On the other hand,I have another idea in my exception function,I want to get more information about the locale of exception,such as the information of the stack,like the vc++'s debug tools!
Thanks!
|
|
|
|
|
Getting a stack trace including source file and line number is possible in both debug and release builds. The key is the EXCEPTION_POINTERS parameter. You need to use the symbols engine API which is in the dbghelp.dll library in the Platform SDK to translate the exception pointers into more useful information.
The best reference I've found for this is "Debugging Windows Applications" by John Robbins. He used to write the Bug Slayer column in MSDN magazine. You can find lots of his archived articles over at the href='http://msdn.microsoft.com'>MSDN site.
There is probably lots of useful stuff elswhere on the web but I don't have any links handy. Google for StackWalk or "win32 stack trace" and you'll probably find some useful links.
HTH
Brad
|
|
|
|
|
when i install ms SDK,systen tell me:
—hrror:System platform Windows2000 was detected,so MSI installation was not performed,however a current MSI installation wat not detected.MSI is required for Platform SDK setup?br />
so i can not install it sucessfully.
what aout it ?how to solve it?
thanks in advance!
|
|
|
|
|
Windows Installer Package (.msi) Files
That's all I know.
INTP
|
|
|
|
|
I want to print the content of a CRichEditCtrl. So far no problem for me, I know how to do it.
My problem is that I have to know the size of RTF text on the paper before I start the printing.
So I have to measure the size of the text depending on the resolution of a DC. If I have to print normal ASCII text I use the CDC::DrawText method with the option DT_CALCRECT which gives me the size of the text section for the given DC. Is there a simmilar method for RTF text?
As a workaround I think of using the CRichEditCtrl::FormatRange method and calculate the size iterative by giving a guessed value for the text rectangle to FormatRange and see, if all charcters fit into the rectangle. Now I size the rectangle until all characters fit into the rectangle.
Has anyone an idea how to solve the problem or is this the only solution?
Thanks in advance.
|
|
|
|
|
There is another solution: using windowless richedit
but you'll need to know COM
1. loadlibrary richedit.dll
2. obtain the CreateTextServices proc : GetProcAddress( hRichDll, "CreateTextServices" )
2. obtain the IID_ITextService : (GUID*)(GetProcAddress( hRichDll, "IID_ITextHost" ))
3. create an instance of ITextHost (a dummy one) .. read the doc
3. call query interfce for the ITextService
IUnknown* unk = NULL;<br />
(*fnCreateServices)( NULL, &m_TextHost, &unk );<br />
unk->QueryInterface( g_RichService, (void**)&m_Service );<br />
unk->Release( ); 4. send the rtf to the service
m_Service->TxSendMessage( EM_STREAMIN, SF_RTF, ... (doc)... )
5. ask the natural size
long forHeight = 1;<br />
SIZEL sze;<br />
sze.cx = forWidth;<br />
sze.cy = forHeight;<br />
<br />
m_Service->TxGetNaturalSize( DVASPECT_DOCPRINT, m_hDC, 0, NULL, TXTNS_FITTOCONTENT, (SIZEL*)<br />
&sze, &forWidth, &forHeight );
i cannot give you the whole source of the implementation of ITextHost because it should be too long, but read the ITextHost doc and implement the strict minimum.
i use that way to create dynamic rtf, calculate rtf display size, print rtf ...
notice that under XP, you should use 'msftedit.dll' instead of 'richedit.dll'
msftedit is really really faster.
good luke
|
|
|
|
|
arg mistake, read that
2. obtain the IID_ITextServices : (GUID*)(GetProcAddress( hRichDll, "IID_ITextServices" ))
|
|
|
|
|
Thank you for your detailed answer!
I hoped I could work with RTF without using COM, but I think I can not escape the Microsoft doctrine.
|
|
|
|
|
CFileFind find;
... ...
CString strTemp = find.GetFilePath();
on WindowsXP with language for non-unicode programs
"English(United States)"
to use CFileFind::GetFilePath to get file path,
the path is "F:\MY MUSIC\MP3\城里的月光.MP3",
which encoding chinese(PRC),
so strTemp get such as "F:\MY MUSIC\MP3\?????.MP3".
Is it unicode issue? How to solve it?
|
|
|
|
|
I just entered this note in my code.
Why?
{
...
CExBitmap exBmp;
exBmp.Attach(bmpBack.GetSafeHandle());
bResult = exBmp.function(...) [this == &exBmp]
{
...
CExBitmap bmpNew;
{
CWorkDC dcWork(NULL,this);
if( !bmpNew.CreateCompatibleBitmap(
&dcWork,newWidth,newHeight) )
{
return FALSE;
}
}
bmpNew.CopyBitmap(this);
HGDIOBJ hNew = bmpNew.Detach();
DeleteObject();
Attach(hNew);
...
return Result;
}
exBmp.Detach();
return Result;
} Solution:
{
...
CExBitmap exBmp;
exBmp.Attach(bmpBack.Detach());
bResult = exBmp.function(...)
{
...
CExBitmap bmpNew;
{
CWorkDC dcWork(NULL,this);
if( !bmpNew.CreateCompatibleBitmap(
&dcWork,newWidth,newHeight) )
{
return FALSE;
}
}
bmpNew.CopyBitmap(this);
HGDIOBJ hNew = bmpNew.Detach();
DeleteObject();
Attach(hNew);
...
return Result;
}
bmpBack.Attach(exBmp.Detach());
return Result;
}
I Known I am missing some thing, but what is it?
INTP (It is not enough to know the solution: you need to know why the solution worked!)
|
|
|
|
|
Well its out of scope for a start
|
|
|
|
|
No it is not out of scope!
INTP
|
|
|
|
|
Daaaa!
Problem:
exBmp.Attach(bmpBack.GetSafeHandle());
...
detach handle
delete handle
attach new handle
...
exBmp.Detach(); // detach new handle
bmpBack.GetSafeHandle() no longer valid
Solution:
bmpBack.Attach(exBmp.Detach());
INTP
|
|
|
|
|
How to real-time get redrew rectangle of screen in remote control application? The redrew rectangle is immediately sent to client.
|
|
|
|
|
There is no such thing as real time [on a computer]!
Assuming you realy want the sceen rectangle and not your client rectangle.
{
CWnd* pDeskTop = GetDesktopWindow()
CRect rcDeskTop;
pDeskTop->GetClientRect(&rcDeskTop);
}
INTP
|
|
|
|
|
Is anyone familar with MSBNx Bayesian Networks, created at Microsoft Research. I have correctly imported the Activex but I get an error here which are arguements into the api function.
<br />
<br />
#include "stdafx.h"<br />
#include "bn.h"<br />
#include "bnDlg.h"<br />
#include "models.h"<br />
.....<br />
void CBnDlg::OnButton1() <br />
{<br />
CModels model1;<br />
model1.Add("jps", "C:\\belief.xbn", "C:\\error.log", ine_Default, recommendtype_Default);<br />
<br />
}
C:\Backup2\projects\bn\bnDlg.cpp(178) : error C2065: 'ine_Default' : undeclared identifier
C:\Backup2\projects\bn\bnDlg.cpp(178) : error C2065: 'recommendtype_Default' : undeclared identifier
I
Add (Models)
http://www.research.microsoft.com/adapt/MSBNx/msbn3/Methods/Add-Models.htm[^]
http://www.research.microsoft.com/adapt/MSBNx/faqs.aspx[^]
all of the example code from MS is in VB
Later, JoeSox www.humanaiproject.org
my friend's Hawaiian Art :
http://www.cafeshops.com/coolroxart
|
|
|
|
|
I have posted several questions on this project, and every answer has gotten me a little closer to my goal. I am stuck AGAIN so, here it goes:
void __stdcall GetAccount(_clsAccount &Acct)<br />
{<br />
HRESULT hr;<br />
dbAccount dbAcct;<br />
<br />
hr = CoInitialize(0);
if (SUCCEEDED(hr))<br />
{<br />
hr = CoCreateInstance( CLSID_clsAccount, <br />
NULL, CLSCTX_INPROC_SERVER, IID__clsAccount, (void**) &Acct); <br />
<br />
if(SUCCEEDED(hr))<br />
{<br />
if(dbAcct.Open())<br />
{<br />
_bstr_t bstr1(_T("This is the test string."));
Acct.put_AccountName(bstr1); ***********<br />
dbAcct.Close();<br />
}<br />
}<br />
CoUninitialize();
}<br />
}
The line Acct.put_AccountName(bstr1); (marked with ***) causes an Access Violation error, and I don't know why.
FYI. If I define the function as
void __stdcall GetAccount(_clsAccount *Acct)
and try to use Acct->put_AccountName(bstr1); to set the value...the same error occurs.
Please help if you can!
Thank you.
|
|
|
|
|
Post the interface and implementation of put_AccountName().
Kuphryn
|
|
|
|
|
this is a little odd, but...put_AccountName is actually defined in a VB DLL I wrote, and is the 'Property Let' method for the AccountName property. The definition, in VB is:
Public Property Let AccountName(ByVal vData As String)<br />
mvarAccountName = vData<br />
End Property
Not much to it. It just stores the string passed to it in a member variable in the Account class. I don't know why, when the object is created in C++, the method is called put_AccountName instead of just AccountName. I assumed that was a default behavior when C++ interprets a VB-defined class object.
Am I way off base here?
Sorry if these are dumb questions...I am VERY new to C++.
Thanks for your help.
|
|
|
|
|
Maybe you should post this on the COM message board
|
|
|
|
|
yeah. I did at first, but then I changed my mind, because I have had such good response on this message board with previous questions.
Thanks
|
|
|
|
|
If I just know the resource ID of a control and it’s not connected to a View statically, I dynamically add the control to the view; the Object ID of that control is not shown in the class wizard of that View.
My question is how to handle events on that control? And how do I know what are the different events triggered by that control? How do I write the handler?
|
|
|
|
|
Take a look at the code the Wizard generates for you - all you need is an ID (which you can pick at random, or use the resource editor to reserve).
Add the message map entries for the event handlers, using the ID you picked to identify the control. Then, use that same ID when you create the control at run time!
Shog9
I returned and saw under the sun,
that the race is not to the swift,
nor the battle to the strong...
|
|
|
|
|
I need a way to create a dialog that is invisible. I am using Chris's tray icon class to control the entire project. I understand ShowWindow(SW_HIDE) but I also want the application NOT to show up in the taskbar.
Best Wishes,
Marty
Update
I found this in msdn!
Visibility of Taskbar Buttons
The shell creates a button on the taskbar whenever an application creates a window that isn't owned. To ensure that the window button is placed on the taskbar, create an unowned window with the WS_EX_APPWINDOW extended style.
To prevent the window button from being placed on the taskbar, create the unowned window with the WS_EX_TOOLWINDOW extended style. As an alternative, you can create a hidden window and make this hidden window the owner of your visible window.
Anyone have an idea on how to do this with a simple dialog?
I can do it with win32 but I was hoping not to lose some mfc classes I need.
Thanks
Marty
|
|
|
|
|
One solution is SetWindowPos().
Kuphryn
|
|
|
|