|
Thanks a lot, i have already fix this trouble, but there is another trouble which is cause by ATL, the errors are:
d:\workshop\file system\all codes\monitor ap\pwcontext\PWFormat.h(33) : error C2787: 'IContextMenu' : no GUID has been associated with this object
d:\workshop\file system\all codes\monitor ap\pwcontext\PWFormat.h(33) : error C2440: 'initializing' : cannot convert from 'DWORD_PTR' to 'const IID *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Generating Code...
This is a simple coding which follow Michael Dunn[^]'s steps,but can't compile under VS.NET 2005.
|
|
|
|
|
This trouble is already fixed! Thanks for your help, everyone!
|
|
|
|
|
as VC6 compiler was far from being standard compliant, even if you don't rewrite your whole application code, you'll have to fix some parts, maybe by rethinking them.
i'm sorry, there's no other way if you still want to compile under VC2005
|
|
|
|
|
Sometimes I wish I had started this project in MFC rather than plain old Win32. When I have finished I think I should go learn MFC and make use of the classes.
Anyway, I am displaying a bitmap in the client area of a dialog. I have no problem with this, but I now want to add some extra functionality. For example I want the user to be able to zoom-in and zoom-out. This isn't really a big problem, just resize the image and display the relevent part.
But this is where I am stuck. If I enlarge the bitmap to say 200%, only 25% of the image is displayed, how would one normaly scroll this? I have been looking through the controls and have found nothing useful.
In the examples on this website, they do similar but use the MFC controls CView, CScroll, etc... I don't have this option. Is there an easier way to do this than creating 2 scrollbars and handling the messages?
|
|
|
|
|
well first of all create a new child window on the dialog and paint the window on that new window (remember to create the window with WS_VSCROLL and WS_HSCROLL so you have scrollbars).
Then handle the WM_VSCROLL and WM_HSCROLL windows msgs (see MSDN for the parameters these message bring), then you can use ScrollWindow function to actually scroll the window.
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
|
I have one CString which contains "MX1200" as its value. I want 1200 from this and I want to store it in a integer variable. How do I do this? Can you show a small code snippet?
Aljechin Alexander
|
|
|
|
|
look at the two functions
atoi()
itoa()
I maybe wrong but I think the atoi() function will only convert the numerical characters from the string, and skip over the non-numerical.
I don't use MFC myself, but there maybe a better way to do this using the MFC classes, I will leave that to the MFC guru's.
|
|
|
|
|
I know its the CRT function atoi(). But its not working for some reason. Thats why I asked for a code snippet. Someone please helpme out.
Aljechin
|
|
|
|
|
perhaps you could post the code you have created, this would give us a better idea of what you are trying and where you may be going wrong.
|
|
|
|
|
Ok, I just tested what I thought and I was half right. atoi will stop at the first non-numerical char, so if your string start with letter you have to remove them.
char *txt = "MX2001";
char *buffer = new char[10];
int pos = 0;
int result;
for (int i=0;i<strlen(txt);i++) {
if ((txt[i] > 0x29)&&(txt[i] < 0x40)) {
buffer[pos] = txt[i];
pos++;
}
}
buffer[pos] = 0x00;
result = atoi(buffer);
Or if your string is fairly constant and always the first two are letter you could
result = atoi(&txt[2]);
-- modified at 1:50 Wednesday 22nd March, 2006
Don't forget to use delete or you will have memory leaks;
|
|
|
|
|
Here is a way to do that.
1. Get length of your CString.
2. Declare a char array of that length and copy your CString to that array.
3. Now the number can easily be extracted from that array.
Here is the code to copy CString to char array
int size = myCString.GetLength(); <br />
char *array =(char*)malloc(size + 1);<br />
strcpy(array, myCString);
If problem remains, do let us know.
Good Luck
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Thank you all. Actually I had been a little dumb. I forgot I was doing a unicode build and should have used _wtoi function and not the atoi function .
Thanks for all of your kind replies.
Aljechin
|
|
|
|
|
Aljechin should have used _wtoi function and not the atoi function .
Always try to use tchar version of functions. Like _ttoi . This way you don't have to worry whether it's unicode or not.
Nibu thomas
Software Developer
|
|
|
|
|
Your welcome.
I wish more people would say thankyou after they have been helped and more people to state what they did wrong or how they fixed the problem. The message boards (not only this site) are filled with questions and no answers or gratitude. It makes searching for a solution a hard task.
|
|
|
|
|
You can always rank helpful replies (bottom right)
We Believe in Excellence
www.aqueelmirza.cjb.net
-- modified at 3:25 Wednesday 22nd March, 2006
|
|
|
|
|
CString str=_T("MX1200" );
int position;
for(int i=0 , str.length(),i++)
if (str.getat(i) <= '9') and (str.getat(i) >= '0')
{
position =i;
//exit;
}
str =str.left(position);
int yourInteger =atoi(LPCTSTR(str));
|
|
|
|
|
|
Hi All,
I had been trying out different websites/books to find out as to what the precompiled header file actually contains but I haven't found any answer.
If any one out there knows what goes in there and would bother to answer this question, I would be highly obliged.
|
|
|
|
|
MFCRookie wrote: If any one out there knows what goes in there and would bother to answer this question, I would be highly obliged.
Well what about stdafx.h .
These files are used to build a precompiled header file Projname.pch and a precompiled types file Stdafx.obj.
These files are located in the Projname directory. In Solution Explorer, Stdafx.h is in the Header Files folder, and Stdafx.cpp is located in the Source Files folder.
stdafx.h
An include file for standard system include files and for project-specific include files that are used frequently but are changed infrequently.
stdafx.cpp
Contains the preprocessor directive #include "stdafx.h" and adds include files for precompiled types. Precompiled files of any type, including header files, support faster compilation times by restricting compilation only to those files that require it. Once your project is built the first time, you will notice much faster build times on subsequent builds because of the presence of the precompiled header files.
Nibu thomas
Software Developer
|
|
|
|
|
Hi Nibu,
Thanks for your response. I would just like to instantiate on this info that you have provided. Could you please tell me whether my understanding is correct? Sorry to keep bugging you.
Let us assume that there is only one line in stdafx.h and that is #include stdio.h . Now, stdio.h contains a function fopen . Taking fopen just for example. Now, is it true that the pch will contain object code for fopen? If yes, then what will stdafx.obj contain? Will it just be the object version of the line
FILE* fopen(const char* filename, const char* mode) ?
|
|
|
|
|
I think that stdio.obj will contain the object code for fopen function and your stdafx.obj will contain only a reference to that function, if any. Good coding and good luck!
|
|
|
|
|
The PCH file contains a tokenized representation of the contents of all headers that were processed. This means all prototypes, definitions, declarations, enumerations, and macros. There is no object code in it. You can thing of it as the results of what is typically the first two passes of a compiler - the preprocessor and tokenizer.
|
|
|
|
|
Hi Rick,
Thanks a lot. Looks like this is what I was looking out for.
Thanks once again.
|
|
|
|
|
What is the difference between the two below
if( NULL != lpDispatch )
and
if( lpDispatch != NULL )
where LPDISPATCH lpDispatch ;
Thanks..
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|