|
OK, here is what I want to do.
- Create a rich edit area on the screen. Using CScrollView as the canvas. I allow the creation of a CRichEditCtrl by dragging an area on the screen. I then use the screen coordinates and create the control.
- Setup the control so it emulates the printer in the word wrapping and font emulation. I use the SetTargetDevice with the width (in TWIPS)and a HDC to the printer. I calculate the width by getting a handle to the DC for the client window, setting the mapping mode to MM_TWIPS, and converting the display points from screen into TWIPs. Calculate the width and call SetTargetDevice.
- Print the contents of the CRichEditCtrl to a printer. I do this by using the same rectangle that I used to create the width for the SetTargetDevice in the FORMATRANGE structure. Fill in the rest and call FormatRange. (Three times, first with (null, false), second (format, true ), and the third (null,false).
Here is what I'm seeing. I draw a box around the control that is +5 screen units bigger (each direction) on the screen and printer. When I type text in the box then do a print preview/print, the characters to the right side of the box, the space seems to be smaller when I print it than when I displayed it. I think the printed version is using a different size font than what is on the display. What this should look like is a text box in word. As an example, create a text box in word, draw a line some where over it (like the middle). Notice what characters it intercets and print. The print output looks like the screen. I would like to do the same thing!
So: How do I create the control so it will appear on the screen as it will when I print?
Thanks
Once I get this beast whipped, all is well with the world. At least in my world!
BTW, there is not much information on how to do this. Either on the MSDN or anywhere else.
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
I hae problem registering my ocx. So I am trying
to debug it using regsvr32 sample program available
at microsoft.com. Does anyone know how to debug using
this regsvr32 program?
Shin
|
|
|
|
|
I just figured out!!
Thanks
|
|
|
|
|
Sorry..
I figured out how to use it..but i don't know the problem
I am getting ctlreg.cpp line 502 assertion error. seemslike
it won't let me trace that deep. If I am getting this error,
where should I look at. any help is appreciated!
shin
|
|
|
|
|
Obviously, Look at MFC\SRC\CTLREG.CPP line 502...
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
Thanks for your posting. Is there anyway that
I can put the break point here?
Shin
|
|
|
|
|
This time it's real. I figure out all!!
No problem registrying the ocx.
Thank you very much!!!!!
|
|
|
|
|
I have a Windows VC++ SDI Application that gathers and process data.
All I want to do is generate a report from data I have collected!!!.
I want to be able to generate a report when I select ‘Generate Report’. (And NOT File -> New)
I also want to be able to Print the report.
I have now idea how to do it.
Please help me.
|
|
|
|
|
Hi,
probaly the easiest approach is before saving your data, you transform the data into a CStringArray. That is for every data you need report you transform this data into a textual representation (CString) and add it to the array.
Then you may store the array into a file. If you take care that a line is not too long, then you may also print that array line by line. Do a heighth calualtion and divide the paper length by this height to get the number of pages to print.
Your application framework should alredy have the appropriate Print(Preview) functions installed.
If you do NOT want to select File New, rename it.
Regards
G. Steudtel
|
|
|
|
|
No it's worse that that, I don't understand how I can get the code to write text to the screen.
I think you need to pretend that I don't understand VC++!!!
|
|
|
|
|
|
Hi guys. Can anyone tell me how I can restrict certain users from having access to certain buttons on my dialog? Since this is a one-off, I'd simply like to have the button in question require a password to activate?
Thanks
Paul
Paul
|
|
|
|
|
If the button in question is on a dialog, then you can simply call the button's EnableWindow() method in the dialog's OnInitDialog() method.
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
m_SomeButton.EnableWindow(...);
return TRUE;
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
What I would do is, say you have a button that performs some functionality that requires a password. In yoru button handler, it might go something like this:
void SomeWindow::Button1Click()
{
Pop up a dialog asking for username/passwordd.
if(!DoSomeFunction(username, password))
{
AfxMessageBox("Nice try, buddy!");
}
}
..
bool DoSomeFunction(username, password)
{
check username and password
If incorrect, return false
Else do the forbidden function and return true
}
You can tweak this as necessary. Somebody else suggested just using EnableWindow(FALSE) on the button. That isn't good because somebody who really wants that functionality (and who can resist trying to hack into something, just because it is password protected?) can use an external program to send Windows messages to enable and click the button. If you have the password check in the function doing the restricted functionality, you can't crack it except by knowing the password or disassembling the code.
If your nose runs and your feet smell, then you're built upside down.
|
|
|
|
|
I hadn't thought of that, thanks.
|
|
|
|
|
I have a question regarding the closing of a CView during a paint message.
I want to send a close message to a view during its OnDraw(CDC*) method. Is it guaranteed that the OnDraw method will finish before the view processes the close message if I send it using PostMessage in my OnDraw code?
Thanks in advance.
|
|
|
|
|
Yes. PostMessage appends the message to the queue of posted messages. SendMessage waits for a response (turns into a recursive call on the same thread).
|
|
|
|
|
OK, thank you. That was what I have expected.
|
|
|
|
|
hey
I have come across an application were i need to change the color of the PUSH Button at run time...
Eg:
I have got some hardware interface like KeyBoard were i'll Depict the KeyBoard in my MFC. If i click the key on my Keyboard of my hardware then I have to dynamically show the change in the MFC also.
so how do i do...
venky
|
|
|
|
|
CButton::SetState in the OnKeyDown and OnKeyUp handlers, I expect.
|
|
|
|
|
Maybe this can help you.
Here is an example I used for a text box.
Override WM_CTLCOLOR message
HBRUSH CMyProgramView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
INT nIDCtl = pWnd->GetDlgCtrlID();
switch(nIDCtl)
{
case IDC_TEXT_BOX:
if (!m_strTextBox.IsEmpty())
{
pDC->SetBkColor(RGB(255, 255, 255));
CBrush br;
br.CreateSolidBrush(RGB(255, 255, 255));
hbr = (HBRUSH)br;
br.Detach();
}
break;
}
return hbr;
}
|
|
|
|
|
Hello,I am interrested in "Windows Media Player Technorogy".
There is "prevent screen capture by user" .
The WMP play a MPEG file.
The user push "Print Screen" key,and copy to clipboad.
but the part of picture in clipboad is black.
I want to realize that function.
I researched around "WM_PRINT" and callback function.
but I can't.
Is there any solution?
|
|
|
|
|
Is it the reaction to WM_COPY? Or is WMP constantly checking the clipboard?
BTW. This is one of the reasons why I never use WMP - sorry Redmond!
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
I want to create the below function.
for example,
My Aplication draw only the circle.
The user push the "print screen" key.
But The picture of my aplication's view is black.
And,,,
I think that WMP doesn't constantly chacking the clipboad.
|
|
|
|
|
One of possible soultion that I'm coming with would be:
1. register one of your hidden windows as ClipBoard viewer, so when capture happens you'll get WM_DRAWCLIPBOARD message (see SetClipboardViewer());
2. on receiving WM_DRAWCLIPBOARD you may look into content and somehow figure out if bitmap(metafile) is something coming from your drawing window (based on size for example and or some other specific features) or maybe empty clipboard always when there is bitmap/metafile in it;
3. If it's you -- post message to your main wnd that will empty clipbrd...
...
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|