|
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
|
|
|
|
|
Good idea Kuphryn
So you think I can eliminate it from the taskbar by using SetWindowPosition? MSDN shows the following parms for SetWindowPos. SWP_HIDEWINDOW will certainly hide the window but it shows in the taskbar.
Best Wishes, Marty
BOOL SetWindowPos(HWND hWnd,
HWND hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
UINT uFlags
);
Parameters
hWnd
[in] Handle to the window.
hWndInsertAfter
[in] Handle to the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values.
HWND_BOTTOM
Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, the window loses its topmost status and is placed at the bottom of all other windows.
HWND_NOTOPMOST
Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.
HWND_TOP
Places the window at the top of the Z order.
HWND_TOPMOST
Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
For more information about how this parameter is used, see the following Remarks section.
X
[in] Specifies the new position of the left side of the window, in client coordinates.
Y
[in] Specifies the new position of the top of the window, in client coordinates.
cx
[in] Specifies the new width of the window, in pixels.
cy
[in] Specifies the new height of the window, in pixels.
uFlags
[in] Specifies the window sizing and positioning flags. This parameter can be a combination of the following values.
SWP_ASYNCWINDOWPOS
If the calling thread and the thread that owns the window are attached to different input queues, the system posts the request to the thread that owns the window. This prevents the calling thread from blocking its execution while other threads process the request.
SWP_DEFERERASE
Prevents generation of the WM_SYNCPAINT message.
SWP_DRAWFRAME
Draws a frame (defined in the window's class description) around the window.
SWP_FRAMECHANGED
Applies new frame styles set using the SetWindowLong function. Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's size is being changed.
SWP_HIDEWINDOW
Hides the window.
SWP_NOACTIVATE
Does not activate the window. If this flag is not set, the window is activated and moved to the top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter parameter).
SWP_NOCOPYBITS
Discards the entire contents of the client area. If this flag is not specified, the valid contents of the client area are saved and copied back into the client area after the window is sized or repositioned.
SWP_NOMOVE
Retains the current position (ignores X and Y parameters).
SWP_NOOWNERZORDER
Does not change the owner window's position in the Z order.
SWP_NOREDRAW
Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of the window being moved. When this flag is set, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.
SWP_NOREPOSITION
Same as the SWP_NOOWNERZORDER flag.
SWP_NOSENDCHANGING
Prevents the window from receiving the WM_WINDOWPOSCHANGING message.
SWP_NOSIZE
Retains the current size (ignores the cx and cy parameters).
SWP_NOZORDER
Retains the current Z order (ignores the hWndInsertAfter parameter).
SWP_SHOWWINDOW
Displays the window.
Best Wishes,
Marty
|
|
|
|
|
ModifyStyleEx( 0, WS_EX_TOOLWINDOW );
Joel Lucsy
|
|
|
|
|
I have to take a test as part of the application process for a specific programming job. A specific question, which I'll post on here, has me a little bit confused, and I just wanted to see if I'm just reading it wrong...I would like some opinions before I write this program incorrectly. Here's the question:
"Write an optimized C program to convert a base 16 number to its base 10 equivalent, without using the standard C libraries, i.e. don't use scanf("%x"). The program should allow the user to input the number. State any assumptions you made when writing the program. Use 23DA as a test number."
Ok, that was the question I have to "answer." Here's what I'm curious about, and would like some insight...if I can't use any of the standard C libraries, exactly how am I to input the number from the user? I am assuming I should keep this as simple as possible and create a console application, which is what I intend to do. How else would I get the input, I mean I could use command line arguments, but that's hardly allowing the "user to input the number." And I still wouldn't be able to display the number without using any of the standard libraries. Please, I need some clarification on this from all of the pros who help us intermediates on this site!!! Thanks so much
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|