|
just write a hook and hook the mouse mesages as u like...
mm i am not sure but u try the follow
in the PreTranslateMessage()
check the message is mouse message and then u handle that message as u like..just trap themm ...
Renjith Pandalam
The TRUE CP -ian
|
|
|
|
|
Hi, pals!
I want to change variable type from CInternetFile* to FILE*.
I am using the following statments,
file2=(FILE*)file1;
Here, the type of file1 is CInternetFile*, and the type of
file2 is FILE*.
I want to know whether my method of type cast (from
CInternetFile* to FILE* ) is correct and safe?
My purpose is to convert from CInternetFile* to FILE*.
Best regards,
George Ma
|
|
|
|
|
Try this :-
Assume m_ifile is a CInternetFile*
FILE *fp = (FILE*) m_ifile->m_hFile;
I am not at all sure whether it will work! But try it anyway!
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
No, a CInternetFile* is not a FILE*. CInternetFile* is a pointer to a class called CInternetFile, while a FILE* is a structure (not a class) for the C Runtime Library. They are two entirely different things, and casting one to the other will do nothing but crash your program (if you're lucky).
There are only three cases where you can cast one pointer to another kind of pointer safely.
1) When the pointer you cast to is a base class of the first pointer.
2) When the class provides a conversion cast to the pointer type you want
3) When a structure (or class without virtual functions) has as it's first member the type you are casting to (this is used often for bitmap headers and such)
Of course this is a generalization, and there are ways around these rules, but if you don't know what you're doing they are good rules to follow.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
Thanks, Erik!
Regards,
George
|
|
|
|
|
Hi.
I have a question about the use of LOGFONT with CFontDialog. I would like to have an option to change the font including size, weight, etc. I implemented a feature with CFontDialog support. I pass a pointer to a LOGFONT object when I instantiate the CFontDialog. Upon DoModal() == IDOK, I create a new LOGFONT object and assign it the value from CFontDialog. The program works sometimes. I am experiencing some weird reactions. First, the size of the font rarely comes out correctly. The size seems to be 10x *smaller* than the actual size of whatever the user selects from CFontDialog. Vice versa, when CFontDialog first starts up, I am able to pass it a LOGFONT of the current font. Again, it reads and interprets the font size incorrectly. For example, all default font size is 110 (11 points). However, when CFontDialog starts up, it interprets 110 as 83.
Here is a concise example.
-----
LOGFONT *mLFont = new LOGFONT;
memset(mLFont, 0, sizeof(LOGFONT);
mLFont->lfHeight = 110;
strcpy(mLFont->lfFaceName, "Microsoft Sans Serif");
CFont *myFont = new CFont;
myFont->CreatePointFontIndirect(mLFont);
// Everything is good up to this point.
CFontDialog myFDlg(mLFont);
if (myFDlg.DoModal() == IDOK)
{
// I am not sure if I need to create a new (clean) LOGFONT object
if (mLFont != NULL)
{
delete mLFont;
mLFont = NULL;
}
mLFont = new LOGFONT;
memset(mLFont, 0, sizeof(LOGFONT));
myFDlg.GetCurrentFont(mLFont);
}
-----
Okay. For some reason, the actual font that GetCurrentFont(...) passes back is 10x smaller than the actual size or the size that the user actually thought it want it to be
I am using CEditView. I use GetEditCtrl().SetFont() to set the font. I use GetEditCtrl().SetWindowText(...) to set the text.
I mentioned about deleting a LOGFONT object and allocating a new object each time I make a change to an LOGFONT object. Is that necessary?
Thanks,
Kuphryn
|
|
|
|
|
Try setting the height like this:
lfHeight = -MulDiv(11, GetDeviceCaps(hDC, LOGPIXELSY), 72);
This comes from the LOGFONT entry in MSDN.
Like it or not, I'm right.
|
|
|
|
|
Okay. The solution is to use CreateFontIndirect() instead of CreatePointFontIndirect(). I have no idea why that is.
Also, when I first instantiate a CFontDialog and pass in a reference of a LOGFONT object of the current font, for some reason CFontDialog does not recognize its height. It only recognizes the height after the user makes changes via CFontDialog.
Kuphryn
|
|
|
|
|
can anyone tell me the software name that i can create avi file please
i downloaded, videdit but i can't install it. it is keep asking missing sample.avi
so i search one avi file and change the name as sample.avi but another error message, " the same is not the same" pop up..
i want to create my own .avi file so i can use animation control of MFC.
thanks
|
|
|
|
|
Win wrote:
i search one avi file and change the name as sample.avi but another error message, " the same is not the same" pop up..
Amazing.
I think an avieditor comes with VC, but I don't remember the name of it. Look in the Tools directory.
|
|
|
|
|
Rama Krishna wrote:
Amazing.
Truly so!!!
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
i meant "the size is not the same"... it was a typo... sorry friends...
|
|
|
|
|
Platypus Animator.
Maxwell Chen
Lets make bugs better!
|
|
|
|
|
|
CAnimateCtrl only can display AVI file?
i want to post my animation .gif file on my dialog but don't know how. I only found a big class on codeguru. but i dont' want an another big class add to my application to run a .gif file. another one is CAnimation, that only can run avi file.. ( from what i understood). i want .gif not avi. anyway. i dont' even know how to create .avi file. what kind of software that i have to use to create avi.. adobe photoshop doesn't have .avi file format when you save.
i think i have to drag picture icon from control box( control box that has all check, radio, animation, treectrl,listctrl,.. etc.) and then just post my .gif on the dialog like other check boxes and radio buttons.
how can i do that? no. can i do it?
|
|
|
|
|
'cause you have to pay money to develop software that deals with .gif files. Search CP; i know there's at least one article on playing .gif files. Or search the Net; there are quite a few AVI creation proggies out there, some free even.
[update]
Just stumbled across this AVI software; give it a look
---Shog9---
Extreme ways are back again, extreme places i didn't know
I broke everything new again, everything that i'd owned -- Moby, Extreme ways
|
|
|
|
|
it's not that difficult all you have is to add an ActiveX control to your dialog called Animation GIF Control .. easy to use .. enjoy it )
MCP
|
|
|
|
|
how? could you tell me please, i have never used activex control. i read activex control from mfc book by Mike Blaszczack. i though activex control is a server type and it is like DLL. that's what i understood from what i read.
now u are saying that i can call animation GIF control. so i looked for it and i could not find animation GIF control when you inserting activex control to your dialog.
i only found
1) animation control 6.0
2) animation control version 5.0
3) direction animation control
4) direction animation path
5) direction animation sequencer
6) direction animation structure
7) direction animation window
so i added each one of them to my applicaiton, but i dont' know how to use them , i couldn't find in MFC lib either.. i search for those classes that activx control created or vc 6 created in MFC and online.. but can't find it.
tell me how to use activex controla and where can i find animation gif control?
i just simple want my gif file running on my dialog.
i didn't except posting gif file on dialog is that difficult..
|
|
|
|
|
why dont u just render each frame to screen? gif are small enuf.
norm
|
|
|
|
|
hi.. all
my application is a printing program.
the program gets all the files from the choosen folder and insert to the tree, ( tree ctrl)
there are checkbox for each tree item.
when the item is checked, do printing, and estimate how many pages those checked files will be printed.
to do estimating and printing, at least one file or one item has to be checked, otherwise, the message "no file is checked". will shows up.
that's basiscally what my program does.
if the program (i just double click on .exe file from debug folder) is run under win2000, and i check on one file, then click on estimate pages button to estimate num of pages that will be print. it gives me num of pages.
but under XP, i did the check the same file, then click on estimate pages button, "no file is checked " message shows up.
why under win2000 works and not under xp eventhough runing the same program, did the same thing, calling the same function?
oh.. i dont' have visual studio under xp though... but i have .dll pasted into my program folder.. so it is runnable under xp too.
|
|
|
|
|
In VC6, WSAGetLastError() returns the proper error code, but in VC7 it doesn't. It returns a system code contrary to the documentation. Anyone know why?
Code-------------------------
#include <iostream>
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#pragma comment (lib, "ws2_32.lib")
using namespace std;
int main(int argc, char *argv[])
{
if (!gethostbyname("www.microsoft.com"))
{
cerr << "gethostbyname error " << WSAGetLastError() << endl;
}
return 1;
}
--- Output from VC6 ---------------------
gethostbyname error 10093
--- Output from VC7 ---------------------
gethostbyname error 5
Another oddity is that VC6 returns almost instantly where vc7 takes several seconds (1.4Ghz machine)
|
|
|
|
|
You apparently haven't even bothered to look up what error 5 is (if you had you wouldn't ask).
|
|
|
|
|
Please read my post before attempting to respond.
If you look in the documentation, gethostbyname() returns "a specific error number can be retrieved by calling WSAGetLastError" it continues on to list several error codes. One of which is WSANOTINITALISED, the correct error code in this case.
WSAGetLastError() does not return the specific error code (consistant with previous versions of VC) but a more generic system error of 5. The question is not what does the returned error message mean but why WSAGetLastError() returns "access denied" and not WSANOTINITALISED?
Does anyone with some experience know?
|
|
|
|
|
I have a function which is being passed a _TCHAR*. I need to find out how long the string is, but when I call sizeof( the_tchar ), it always returns 4, no matter what the string, which of course tells me that it is returning the size of the pointer, not the string. How do I get the length of the string being pointed to by the _TCHAR*?
|
|
|
|
|