|
Hi,
I am working on printing a List Box contents, so far it has worked ... except that I could not change the "Text size", here is a part of my codes:
<br />
CFont Font;<br />
LOGFONT lf; <br />
CDC dc;<br />
<br />
memset(&lf, 0, sizeof(LOGFONT::ZeroMemory(&lf, sizeof(LOGFONT));<br />
lf.lfHeight = -MulDiv(10, dc.GetDeviceCaps(LOGPIXELSY), 72);<br />
strcpy(lf.lfFaceName, "Arial"); <br />
<br />
Font.CreateFontIndirect(&lf);<br />
dc.SelectObject(&oFont); <br />
CString text("A") ;<br />
CSize csText = dc.GetTextExtent(text) ;<br />
----------------------------------------------- (some more detail)<br />
m_listbox.GetText(line_printing, text) ;<br />
dc.DrawText(text, CRect(x, y, x + Info.m_rectDraw.Width(), y + csText.cy), DT_EXPANDTABS) ;<br />
<br />
*) I tried to change lf.lfHeight, but the result is that I only changed the spacing for vertical printing! What ever I change that or lf.lfFaceName ... the "Text size" printing out ... has never been changed!
Can someone help me on this, I am really appreciate it ... if provide me an Email ddress, I will send a small zip about my small project (just to try the printing)!
Many thanks,
|
|
|
|
|
Are you sure that dc you're using to call GetDeviceCaps is actually printer DC?
Also, you may use CFont::CreatePointFont to avoid bit-twiddling.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Hi,
I did try to use as your suggestion:
VERIFY(oFont.CreatePointFont(80, "Arial", &dc)); // 120 = 12 point font
for replacing:
// oFont.CreateFontIndirect(&lf); // Create the font.
// dc.SelectObject(&oFont); // RIA, select he font into the DC
The result was the same Text size! Someone knows why?
- For the GetDeviceCaps is actually printer DC? I think Yes, because we have to use to calculate the Paper size ... and so far it is OK!
Many thanks for any help
|
|
|
|
|
Ok I am going to try and explain this without confusing both you and myself. I have a file that I am writing custom CObjects to. The first thing written/read from the file is the number of objects that are in the file… so I know how many times to read from the archive.
Say that number is 5, and then I close the file, open it again, and rewrite more objects now the number is 10. Do I have to clear the file and rewrite all the objects? If I do not clear the file, and just write at the start position or will this corrupt the file because it will be overlapping the first object.
To make it even more confusing, do I have to include the number of objects, or is there an easier way. My overall objective is to create a log file, so I subclassed CObject, to create my own objects… to make it easier to write.
If you have any answers to one or all of my questions, I would GREATLY appreciate it. I have read MSDN, but am very confused about how it works… I know it’s hard to create your own file format. Thank you for your time.
"Best file compression around: DEL *.* = 100% compression."
<><><><><><><><><><><><><>
Matthew R. Miller
mattrmiller@computersmarts.net
www.computersmarts.net
|
|
|
|
|
Hi Mathew,
I'm reasonably sure CArchive is only a streaming format, which means you can't selectively write to a part of the file. ie. In your example the count of objects at the start. Appending to an existing archive should work ok.
I use a similar technique to the one you describe to manage an array of Style Sheets in ED (see sig). When I want to save the style sheets array I recreate the file from scratch as follows:
if ( bStat = SSfile.Open( m_SSFileName, CFile::modeCreate | CFile::modeWrite | CFile::shareExclusive, &FileException ) )
The count is written at the start of the file.
If you want to be able to append to the file and modify a header record I don't think CArchive is appropriate.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
|
Just a quickie,
I have one member function
HWND CAutoRestartDlg::GetProcessWnd()<br />
{<br />
... <br />
EnumWindows((WNDENUMPROC)CAutoRestartDlg::GetWndProc,(LPARAM)0);<br />
....<br />
}
and also my callback function:
BOOL CALLBACK CAutoRestartDlg::GetWndProc(HWND hwnd, LPARAM lparam)<br />
{<br />
...<br />
}
When I try to compile, I get error C2440: 'type cast' : cannot convert from '' to 'int (__stdcall *)(struct HWND__ *,long)'
What am I doing wrong? Would appreciate some help. Sorry if it sounds a bit thick but I am feeling very thick at the moment.
Many thanks
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
|
Thanks Joaquin,
I can't see for looking some days. I appreciate your help!!
Cheerio for now and thanks once again.
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
Make sure GetWndProc is declared as a static function in your CAutoRestartDlg class. Most any time you define a Win32 API callback function inside a class you need to make the function static. This is because the Win32 API is written in C and C can't handle C++ classes and their polymorphic abilities. The API needs to know at exactly what position in memory your function resides so that it can call it. Polymorphism allows run-time determination of function addresses. Static functions -and static member variables, too- are allocated once when your app begins and never move for the duration of your app's existence. Only one copy of a static function exists in memory for the entire class; regardless of how many instances of the class you create.
Static functions are basically identical in nature to any old C-style function you'd create outside of your class. The only difference is that they're located in your classes' namespace, so you can keep things neat and know where to look for the code. That's really the only reason why they're even allowed in a class; you don't get any object-oriented features with static functions.
One additional note to preempt further frustration... static functions inside C++ classes cannot directly access anything inside the class except other static member variables or static functions. IE if you had an integer member variable named m_iMyVar, you could not read it nor set it unless it were also declared as being static. This is because only one copy of the function for the entire class exists; it would not know which object instance to use when setting the member variable or calling the other function. If you want to actually use something inside your CAutoRestartDlg class you'll have to use the LPARAM portion of your call to EnumWindows() and pass along a pointer to the class or a struct which contains a pointer. I can whip up some code if you'd like to see an example of this.
Sorry for the over-explanation if you knew this stuff already I guessed from your code that you probably already tried various casts.
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
Hey Ty,
That's excellent. A big THANKS! Really, more explanation is better than less, for me anyway. I got really fed up late last night wondering I kept getting the error message and not being able to figure it out. It's just that the explanation of the error does not give any indication that the function would have to be declared static. Hence my frustration!
Thanks once again! Totally appreciated.
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
Okay, now you have managed level 1, let's go up to level 2
Using only static member functions (also called class functions) or ordinary C functions as callbacks is boring and odd. But you can use adapters to "translate" a call to a static function seamless into a call to a real member function.
If you are interested in more technical details about the "callback has to be static" issue and a complete solution for it you may want to check out my article Use member functions for C-style callbacks and threads - a general solution.
However, you don't have to read the whole article, you could also just use the provided adapters. It allows you to write code as simple as the following:
#include "stdafx.h"
#include "win_adapter.h"
struct DATA { int foo; double bar; };
class Test
{
public:
virtual BOOL WindowLister( HWND hWnd, const DATA& data )
{
printf(" Window: %p\n", hWnd );
return true;
}
void DoStuff()
{
DATA someData;
win::EnumWindows( this, &Test::WindowLister, someData );
}
};
Programming is fun!
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
What is the best way to smooth window movement on static controls such as picture controls in msvc++ and mfc.
i currently use,
hStruct.HSliderCover = iLoadBitmapFromFile( "graphics/slider_cover.bmp", 0 );
m_picSliderCover.SetBitmap( hStruct.HSliderCover );
m_picSliderCover.SetWindowPos( &wndBottom, 0, 0, 553, 62, SWP_NOMOVE );
CRect rect;
m_picSliderCover.GetWindowRect(rect);
SetTimer( SliderTimer, 1, NULL );
//slider timer
if( nIDEvent == SliderTimer )
{
rect.left++;
m_picSliderCover.SetWindowPos( &wndBottom, rect.left, 420, 0, 0, SWP_NOSIZE );
}
any help would be great.
|
|
|
|
|
There are most likely lots of ways to do this, including the one you're using. My two suggestions are:
- Use a borderless popup window displaying the bitmap, move it - should be accelerated on any not-completely-worthless OS+video card. Or,
- Save an image of the portions you are covering to memory, and then use a separate in-memory bitmap to draw part of it covered by your slider each timer interval; then draw the complete image to the screen in one go.
Shog9
------
If you really what to get shitfacde tell a crowded bar that is is yourt borthday and hife your wallet. you ka will many more friends.
- David Wulff, Brithday selebrations, 9/19/02
|
|
|
|
|
On the users machine, my install program will register the VB com dll automatically. Question is where should I put my VB Com dll? Does it matter? Or will the app go to the registry and locate it itself? The method I'm using to hook the dll has code like :
_ClRemoteCall p;
p.CreateDispatch("DllwithForm.Class1");
and I go through the class wizard .
Thanks,
ns
|
|
|
|
|
If the DLL is specific to your progam (as I guess it is), then it is best to copy it to the target directory where all other stuff belonging to the app inhabits. The registration process takes note of the path where the DLL is, so you have complete freedom to choose its location.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Good to know for sure
Thanks,
ns
|
|
|
|
|
Hi
I'm trying to paste bitmap from program resources into a clipboard:
#ifdef UNIETSIOFFICE_EXPORTS
#define UNIETSI_API __declspec(dllexport)
#else
#define UNIETSI_API __declspec(dllimport)
#endif
int UNIETSI_API WINAPI uniETSIOfficePasteIcon(int nIconId)
{
CBitmap Bitmap;
Bitmap.LoadBitmap( nIconId );
OpenClipboard( 0 );
SetClipboardData( CF_BITMAP, Bitmap );
CloseClipboard();
}
This function is in mfcdll(mfc is linked statically) and everything works perfect in Win2000 (in which I have made my dll) but when I have tried this in Win98 nothing appears in clipboard(dll works, my function executes, all functions used in this code seems to work - return code !=0 - but nothing appears in clipboard). I don't know what is wrong.
Greetings
Mariusz Popiolek
|
|
|
|
|
Is it an icon that you're trying to load? If so, try loading a bitmap instead and see what happens. If is the icon bit that is failing, you might want to use LoadImage instead.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm trying to paste bitmap, but I will try to use LoadImage, maybe it will solve the problem (I hope).
Greetings
|
|
|
|
|
Try adding EmptyClipboard() call after OpenClipboard.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
I have an app that has uses the Webbrowser ActiveX object. My problem is that the web site that the Web Browser should show needs to be current and not taken from the history, temp file, or cashe. What I want to know is how to delete or prevent the history, temp internet files, and or cashe from displaying old material, instead it should get the data from the Web Server everytime(Plus be able to detect if it is offline or not).
If anyone can put point me to the river which contains this information, or show me how it is done, I shall be very gratefull. Thanks in advance Shell Gurus and Friends for your advice and guidance!
|
|
|
|
|
First of all, a way to make sure the web page is always up-to-date, is to use the expires meta-tag with 0 as value :
<META HTTP-EQUIV="expires" CONTENT="0">
Now it's easy if you generate yourself the served web pages.
If you don't, you'll need to use the web browser control API IHTMLMetaElement to update the current web page.
More info on syntax here[^].
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
I have a better answer for you. Hope you like it.
See here[^].
Yes, to do what you need you just need to set the IE settings.
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
Hi everyone,
I was searching the net for some programming resources and I stumbled upon this site. I'm looking to eventually get a posistion in the game developing business, but firstly I need to gain experience in programming. I'm 19, and going to college next fall, and I was wondering if maybe you guys could help me out. What is the ideal degree to have for a job in the programming field? I'm very computer literate, but have no knowledge of programming. The most well known language to me, or atleast most heard of, is C++. Would it be wise to perhaps buy Visual C++ and start working with it on my own? It would seem advantageous to me, if I know a bit of computer programming even before I went to college for my degree. Lastly, are there different programs to write C++? Or is it just Microsoft that makes the product?
Thanks,
Brandon
|
|
|
|
|