|
Does anyone know of any algorithms to convert degrees to pixels. I need to be able to rotate a bitmap by a given degree.
|
|
|
|
|
|
As degrees are an angular measure and pixels lateral the convertion would depend on how far from the rotation point you are. I have been playing with images for a while now and was going to write a lot of the code myself, but found it was better to concentrate on the rest of the project and do the image handling with a library written be someone who has more experience than I do. In the end I opted for ImgSource
http://www.smalleranimals.com/
It is inexpensive (note I don't say 'cheap') and does a very good job for what I need to do. Have a look it may do what you want.
Happy programming!!
|
|
|
|
|
Is there a way to understand if a port is listened by a server process on winsock ? If you know how to do this can you post a code sample.
Orcun Colak
orcuncolak@yahoo.com
|
|
|
|
|
What do you actually mean?!?!
You want a 'client' be able to test if a 'server/service' exist on a service-port over UDP?
UDP is a connectionless protocol, so the only way for the 'client' is to check the connection is waiting for any response on your message.
I write 'client' and 'server' between brackets, since client-server in UDP environment is not really a client-server architecture. With TCP/IP you split a socket when a connection is make (by listen -> accept), UDP doesn't do this, but you can use recvfrom to collect the others ip-address+port.
EiSl
|
|
|
|
|
I'm using CToolbar in an MDI w/ sliders,edits,comboboxes,etc.
And I need to place multiple rows of buttons for
one toolbar.I can make the toolbar wider, but I
don't know how to wrap the buttons on the toolbar
to make multiple rows.I've tried getctoolbarctrl(?)
but i can't get a wrap.
|
|
|
|
|
One of the examples on this site explaines the usage of multiple checkboxes in one 'placeholder' In stead of checkboxes buttons should be possible to. Be care full about keeping the GUI user friendly!
Give a yell if you need more help
EiSl
|
|
|
|
|
Does anyone know of a quick and easy way to encrypt / decrypt a phrase stored in a CString variable?
I'm looking for 40 bit (or lower) encryption that uses a hardcoded key for encryption / decryption.
Can anyone point me to a good resource, or give me some pointers?
Thanks,
Frank
|
|
|
|
|
You might try Wei Dai's Crypto++ library. It is:- easy to use,
- very C++ oriented,
- cross-platform,
- open source and royalty free.
There's an article on CodeProject with an example of use.
Regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I looked at Crypto++ and backed away from it for these reasons:
<l>
Way too much for what I need...I just need a simple encrypt/decrypt function.Import / Export restrictions. I think that 40 bit is cool with the US DOD, but i'm not exactly sure.
All I really need is a way to encrypt registration information for my app that is secure but at the same time not too difficult to implement. I've tried XoR and a few other "Simple" encrypt / decrypt methods but they dont seem to fit well into my scheme of things. If I could be specific, I'm looking for something that will give me an output similar to a PGP public key signature you would receive in an email.
Thanks for the suggestions,
Frank
|
|
|
|
|
But it's need to allow the writing only to my program.
Is it possible ???;)
|
|
|
|
|
When you crete the file, you must not put the otion shared
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
First, create your file, then:
SetFileAttributes(lpFileName, FILE_ATTRIBUTE_READONLY);
Of course i'm not sure ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Can a CRuntimeClasses be serialized using a CArchive. Can it be done by using code like this
CRuntimeClass *runtimeclass = RUNTIME_CLASS(CRandomClass)
ar << runtimeclass; or by
CRuntimeClass *runtimeclass = RUNTIME_CLASS(CRandomClass)
ar.WriteObject(runtimeclass); or is there another more complex solution?
Joel Holdsworth - the child eating devloper
'My cup of tea has caught fire!'
|
|
|
|
|
|
Hey folks,
I've been working on some code for some time which simply draws interconnecting boxes with text on the screen using the basic window calls to illustrate some kind of network connectivity. (Box represents a server, lines represent some kind of cabling between that server, and another).
For fun, I thought it would be great if I could implement some kind of "ZOOM" function which would change the sizes of the boxes dynamically, then choose a font which would fit in the new boxes.
I created a pull-down from the window I created, and added a resource for "10%", "25%", "50%", 100%", "200%", where 100% is the NORMAL view when you launch this window, 50% being half of the original etc, you get the idea.
When a user clicks on one of my "Zoom" items, I initialize a global variable called ZoomFactor which contains the ratio of how the diagram is to change. (ie. ZoomFactor == 1, denotes 100%, or normal view, ZoomFactor == 0.5, denotes half the original).
When the time comes to "build" the diagram again, I dynamically determine the new cell size by using the code below:
// Set our cellsize to be our zoomed cell size.
GetTextExtentPoint32 ( hdc, "A", 1, &szorgFontSize );
szZoomCellSize.cx = (LONG)(szorgFontSize.cx * ZoomFactor );
szZoomCellSize.cy = (LONG)(szorgFontSize.cy * ZoomFactor );
// Set the size of my server box width, by multiplying
// the new cell X size, by the maximum number of chars/server box.
ServerBoxWidth = szZoomCellSize.cx * MaxServerChars;
NO Problems, everything is great, my szZoomCellSize is scaled properly, my box sizes change as they should, Problem comes when I want to create an appropriate font for the new cellsize.
Basically, I want to create a font which will fit in the szZoomCellSize rectangle, I make this call in hopes that the font it creates will fit insize of the ZoomCell.
// Setup our new font
hfont = CreateFont ( szZoomCellSize.cy, 0, GM_COMPATIBLE, GM_COMPATIBLE, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEVICE_PRECIS, CLIP_LH_ANGLES,
PROOF_QUALITY, FF_MODERN, lfnt.lfFaceName );
After I made this call, I noticed that in many cases, the font that it choose had a proportionate height and width (the font didn't look stretched), but was often TOO big for the box I've created. I added a "GetTextExtentPoint32" call after the create font and found that the font it picked was in most cases, LARGER than the "szZoomCellSize.cy" I specified. I understand that most fonts are NOT fixed width, so I even change the character in both "GetText" calls to "M", because M is usually one of the bigger characters, no go, same results.
I've spent some time looking through "CreateFont" and found it to be a little out of my league... By no means am I an expert graphics guy, just need a basic explanation! Anyone? Ive heard I can also create a bitmap of sorts, and just StrechBlt it, but I'm leaning NOT to do that...
Anybody see what I'm doing wrong here?
Much appreciated,
Mike.
|
|
|
|
|
First things first: you should negate the szZoomCellSize.cy. Details are in CreateFont docs
The second thing is that you're not guaranteed to get all character widths multiplied by X when you're scaling height by X. Scalable fonts can have hints and rendered bitmaps may have slightly different widths. You should just use DrawText with DT_END_ELLIPSIS flag to automatically display '...' if there's not enough space to display all characters in the box.
I've heard I can also create a bitmap of sorts, and just StrechBlt it, but I'm leaning NOT to do that
Don't StetchBlt. The algorithm used by this function is simple and fast - it doesn't perform any interpolations and resulting image looks ugly when scaling factor is not 2, 4, etc.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thomas,
Thanks for your reply.
I'm not quite sure what you mean by "negate", sounds silly and all, but do you mean put a "-" in front of my szZoomCellSize.cy?
hfont = CreateFont ( -szZoomCellSize.cy, 0, GM_COMPATIBLE, GM_COMPATIBLE, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEVICE_PRECIS, CLIP_LH_ANGLES, PROOF_QUALITY, FF_MODERN, lfnt.lfFaceName );
I've made this change, and I'm still finding that the font its creating is larger than the HEIGHT I've specified. Is there a way or flag what would tell CreateFont to take the closest, lesser nHeight it can find?
In my code, everything revolves around the size of the font. Before I draw the text using the "ExtTextOut" with the ETO_CLIPPED option, I call "GetTextExtent32" to find out the average height and width of a characer. I then build a rectangle to which the text "should" fit. If the font "CreateFont" picks is larger than the box, then my rectangle and font will inevitably fall out of the box. You see my problem
By the way, I downloaded your screen saver app, great job...
Thx.
Mike.
|
|
|
|
|
I call "GetTextExtent32" to find out the average height and width of a characer.
Well, this is an average width. I think the best solution would be using DrawText instead of GetTextExtent32/ExtTextOut. You can use DrawText with DT_CALCRECT - in this case, nothing is drawn - the function calculates the rectangle needed to fit your string. So when user zooms in/out, you should create a font with given height, then paint all boxes using rectangle returned by DrawText called with DT_CALCRECT.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Have you tried using DrawText, seeing as you already have a rectangle in which you what the text to fit.
I am not too sure as to what this does to the actual font you have selected in the DC at the time, but I do know that there is a flag that will scale the text to fit in a given rectangle.
Hope this help
AndyC
|
|
|
|
|
Andy,
I'm using ExtTextOut with the ETO_CLIPPED option. This works the same way as DrawText, my problem comes when the font is created, its TOO big based on the nHeight I specified.
I build a rectangle object using the limits of the box that is to be created dependant on the zoom factor etc, but the font it creates is LARGER than the box I've created. whooops!
I'd have to show you in a screen shot or something! Any ideas?
Thx.
Mike.
|
|
|
|
|
I am creating listbox, where the user can select one or more items. I wnat my software to be such that even after the user makes the selections, clicks OK, and then opens the same dialog (with the listbox in it), he/she would see tha last selections made highlighted in the listbox.
In short I want the listbox to show the last chosen settings.
How do I do that??
It is what we choose to be that makes us what we are, far more than our abilities.
-J.K. Rowling
|
|
|
|
|
You should store the selection in CYourDlg::OnOK, and re-load it in CYourDlg::OnInitDialog (after the call to CDialog::OnInitDialog). Do you use item data in listbox?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Ok,
I'm rather new to this, so I'm stumped... but I don't think it should be too hard...
I have a window-based app with buttons. When certain buttons are clicked, lenghty processes are started. I want a modal dialog box to display with a message like "Wait..." (or perhaps a progress bar) when the button is clicked and then be undisplayed when the process is finished. It's important that mouseclicks on the main window's buttons are ignored when the process is underway (that's why I want the dialog to be modal).
This seems like it should be simple, but I don't understand how I can call DoModal(), get the window displayed, get the process started, wait for the process to finish, and then do an EndDialog()... this must be a pretty common task, but I don't see how to use the CDialog framework (or derivation of it) to get the job done.
thanks! any help is appreciated!
m-flury@northwestern.edu
|
|
|
|
|
In VC++ help, go to 'Contents' tab, then Periodicals - 1997 - MS Systems Journal - February - Wicked Code. The article by Jeff Prosise has a solution for your problem.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|