|
Hi
I'm developing an application which interfaces with Internet Explorer using COM.
I have a problem compiling my code due to typedef redefinitions. Whilst I understand the cause of the compiler error, I cannot figure a way around it. My application is #import'ing mshtml.tlb. This causes the compiler to automatically create 'mshtml.tlh', which redefines some existing typedefs. The worst thing, is that mshtml.tlh (which is not editable due it being regenerated every time you compile) defines UINT_PTR as an unsigned long *, so it differs with the existing definition which is of course unsigned int *.
None of these typedefs are mine, and i do not sepcifically include BaseTsd.h or WinGDI.h
I could really use some suggestions as to how i can resolve this problem.
Here's the output :
TestIEConnectWithCOM.cpp
c:\TestIEConnectWithCOM\Debug\mshtml.tlh(957) : error C2371: 'UINT_PTR' : redefinition; different basic types
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\BaseTsd.h(90) : see declaration of 'UINT_PTR'
c:\TestIEConnectWithCOM\Debug\mshtml.tlh(76516) : error C2011: 'tagLOGFONTW' : 'struct' type redefinition
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\WinGDI.h(1167) : see declaration of 'tagLOGFONTW'
Jase
|
|
|
|
|
I believe you can provide a different namespace name, to avoid the conflict. More info here[^].
|
|
|
|
|
Thanks for your reply. The article you linked me too has helped me fix the problem.
I'm not well acquainted with namespace's, and the article showed me you can exclude symbols as follows :
<br />
#import < mshtml.tlb > named_guids no_namespace exclude("UINT_PTR", "tagLOGFONTW")
Thanks again for you help.
Jase
|
|
|
|
|
I'm trying to take multiple small bitmaps, BitBlt them into a memory dc then
using a mask, draw them transparently to the screen. With one bitmap from a file it works fine, but when I combine them to an in memory DC and do the transparent blt, the colors get screwed up.
|
|
|
|
|
try to use TransparentBlt() , it uses chroma key to apply the transparency, and much easier
BOOL TransparentBlt(
HDC hdcDest,
int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int hHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthSrc,
int nHeightSrc,
UINT crTransparent
);<pre>
if you are using VC++7 you will find it in the CDC class, otherwise you should use this API version
|
|
|
|
|
I try to set bitmap on button but without success?
CButton xxx;
xxx.SetBitmap(::LoadBitmap(NULL,MAKEINTRESOURCE(IDB_BITMAP1)));
why this does not work?
Best regards,
Axe.
|
|
|
|
|
if you set the button syte to BS_BITMAP and the LoadBitmap returned a valid handle this function should work, otherwise somthing else may be wrong
|
|
|
|
|
which function is in the middle of CAppWin::OpenDocumentFile() and CDocument::OnFileOpen()?
because app crashes after call CAppWin::OpenDocumentFile() and before reach to CDocument::OnFileOpen().
thx
includeh10
|
|
|
|
|
What about using the debugger call stack ?
|
|
|
|
|
hello
i would to find a function that can know if the CDROM DRIVER work or not or in other way if it read or no.
|
|
|
|
|
Hi guys, I'm Pete an IT technician from the UK, previosly i only ever delt with Visual Basic but unfortunatly for a course i'm doing i have to write a program in C++ and everything i'm trying comes out wrong - i would be very greatfull if anyone could post examples of any code that could help me.
The task is to write the code for a simple ATM simulation
-When started a welcome message shoudl appear
-The user must then register their details to open an account
once the user has sucessfully registered their details a logon screen shoudl appear asking for thier pin number
-3 wrong pin numbers would result in the program shutting down
-A valid pin entry would take the user toa menu syetem with the following options.
Withdraw Cash
Deposit Cash
Request an overdraft
Quit
The program must display these menu options untill the quit option is chosen
An overdraft will be apporoved automatically if the user has over £500 in their account, if the user has between £250 and £500 then they must seek approval from their branch. if they have kess than £250 they overdraft request would be rejected.
I realise this is a long way below the levels of most of you guys but any ideas or sample codes would be greatly appreciated
|
|
|
|
|
I doubt you will receive any extensive help in terms of actual code. I recommend that you start the project and then post specific questions.
Kuphryn
|
|
|
|
|
Well unfortunatly i don't really know enough about C++ (and programming genrally) to ask any specific questions
i'll paste the code here (bearing in mind how new i am to this so it's very basic and untidy) - any tips anyone could give me would be greatly apprieciated
Cheers
}
<br />
<br />
<br />
<br />
<br />
#include<iostream>
#include<stdlib.h>
using namespace std;
<br />
int main()
{<br />
int pin =1234;<br />
int reg =0;<br />
int wrongpin =0;<br />
int mmchoice =0;<br />
int withdraw =0;<br />
int money =0;<br />
int deposit =0;<br />
<br />
cout<<"Welcome To Petes Bank "<<endl;
cout<<"Press any key to continue..."<<endl;<br />
system("pause");<br />
<br />
cout<<"Do you wish to register with us? "<<endl;
cout<<"1 - Yes"<<endl;<br />
cout<<"2 - No"<<endl;<br />
cin>>reg;<br />
system("pause");<br />
<br />
while ((reg !=1) && (reg !=2))<br />
{ <br />
cout<<"Error please retry"<<endl;<br />
cout<<"Press Any Key"<<endl;<br />
system("pause");<br />
cout<<"Do you wish to register with us? "<<endl;
cout<<"1 - Yes"<<endl;<br />
cout<<"2 - No"<<endl;<br />
cin>>reg;
}<br />
<br />
if (reg==1)<br />
{<br />
cout<<"How Much do you have in your acount"<<endl;<br />
cin>>money;<br />
<br />
cout<<"Your Pin is 1234"<<endl;
system("pause");<br />
system("cls");
<br />
cout<<"Please enter pin"<<endl;<br />
cin>>pin;<br />
<br />
while ((pin !=1234) && (wrongpin !=3));<br />
{ <br />
wrongpin = wrongpin+1;<br />
cout<<"Error Wrong Pin"<<endl;<br />
cout<<"Please enter pin"<<endl;<br />
cin>>pin;<br />
<br />
}<br />
else if ((pin==1234) && (wrongpin !=3));<br />
{<br />
cout<<"Welcome to the Main menu"<<endl;<br />
cout<<endl;<br />
cout<<"/t /t Please Select from the following options"<<endl;<br />
cout<<endl;<br />
cout<<"1 - Withdraw Cash"<<endl;<br />
cout<<"2 - Deposit Cash"<<endl;<br />
cout<<"3 - Request Overdraft"<<endl;<br />
cout<<"4 - Quit"<<endl;<br />
cin>>mmchoice;<br />
<br />
while ((mmchoice !=1) && (mmchoice !=2) && (mmchoice !=3) && mmchoice !=4)<br />
{ <br />
cout<<"Error please retry"<<endl;<br />
cout<<"Press Any Key"<<endl;<br />
system("pause");<br />
cout<<"Welcome to the Main menu"<<endl;<br />
cout<<endl;<br />
cout<<"/t /t Please Select from the following options"<<endl;<br />
cout<<endl;<br />
cout<<"1 - Withdraw Cash"<<endl;<br />
cout<<"2 - Deposit Cash"<<endl;<br />
cout<<"3 - Request Overdraft"<<endl;<br />
cout<<"4 - Quit"<<endl;<br />
cin>>mmchoice;<br />
}<br />
<br />
else if (mmchoice = 1);<br />
{<br />
cout<<"How much would you like to withdraw?"<<endl;<br />
cin>>withdraw;<br />
system("cls");<br />
money = money - withdraw<br />
cout<<"Please take your "<<withdraw<<" Pounds"<<endl;<br />
cout<<"Your Balance is "<<money<<" Pounds"<<endl;<br />
system("pause");<br />
<br />
return 0;<br />
}<br />
else if (mmchoice = 2);<br />
{<br />
cout<<"How much would you like to Deposit?"<<endl;<br />
cin>>deposit;<br />
system("cls")<br />
money = money + deposit<br />
cout<<"Your Balance is "<<money<<" Pounds"<<endl;<br />
system("pause");<br />
<br />
return 0;<br />
}<br />
else if (mmchoice = 3)<br />
{<br />
if (money >500)<br />
cout<<"Your overdraft has been approved!"<<endl;<br />
<br />
system("pause");<br />
<br />
return 0;<br />
<br />
if ((money <=500) && (money >250));<br />
cout<<"Please contact your branch"<br />
system("pause")<br />
<br />
return 0;<br />
<br />
if (money <=250);<br />
cout<<"Sorry you cannot have an overdraft"<br />
system("pause")<br />
<br />
return 0;<br />
}<br />
<br />
else if (mmchoice = 4);<br />
{<br />
cout<<"thankyou for using Pete's bank"<br />
system("pause")<br />
<br />
return 0;<br />
}<br />
<br />
<br />
}<br />
else if ((pin!=1234) && (wrongpin ==3))<br />
{<br />
cout<<"Sorry you have Entered the wrong pin 3 times, the system will now shut down"<<endl;<br />
system("pause");<br />
<br />
return 0;<br />
<br />
}<br />
<br />
if (reg ==2)<br />
<br />
cout<<"goodbye"<<endl;<br />
system("pause");<br />
<br />
return 0;<br />
<br />
|
|
|
|
|
The other poster was right - we're glad to help, but we won't do your homework for you.
Pete Forster wrote:
#include //IO Library Mandatory
#include //Standard Library for DOS commands Mandatory
//#include //Includes String library
using namespace std; //For object orientation Mandatory
As a matter of form, it's better to use the syntax
using std::endl;
using std::cout;
etc. Do you *need* to use the dos library ? I think it's a bit ugly, personally.
Also, the includes didn't show up because you didn't tick 'display this message as-is', or use the buttons above the smileys to put in <> as < >. I presume you included <iostream> and <string> as opposed to <iostream.h> and <string.h> ? If not, the code is wrong and reference to namespace std is superfluous.
Pete Forster wrote:
cout<<"Please enter pin"<<endl;
cin>>pin;
while ((pin !=1234) && (wrongpin !=3));
{
wrongpin = wrongpin+1;
cout<<"Error Wrong Pin"<<endl;
cout<<"please enter="" pin"<<endl;
cin="">>pin;
}
else if ((pin==1234) && (wrongpin !=3));
Your while and if statements have semicolons after them. I suspect this is your main problem. The semicolon means that the code afterwards is always run. This can be valid, a loop and perform the desired actions by itself at times, but you want this
while (pin != 1234 && wrongpin <3 ) // no semicolon and extra brackets were superfluous.
{
++wrongpin; // Same as wrongpin = wrongpin + 1
// etc.
}
I'd also be inclined to use do...while loops so your input statement need only occur the once.
Pete Forster wrote:
while ((mmchoice !=1) && (mmchoice !=2) && (mmchoice !=3) && mmchoice !=4)
Just a suggestion, but this would be tighter as
while (mmchoice < 1 || mmchoice > 4)
Also, you created all these variables at the top, and a lot of them are just reused temporaries. C requires variables declared at the top, for C++, I prefer to declare them as I need them. They are only ints today, but if you're creating something resource hungry, it's better not to do it until you need it. ( Of course, if your teacher is an old C programmer, he may disagree and it may cost you marks, so ask him/her first )
Pete Forster wrote:
if (money >500)
cout<<"Your overdraft has been approved!"<<endl;
system("pause");
return 0;
if="" ((money="" <="500)" &&="" (money="">250));
cout<<"Please contact your branch"
system("pause")
return 0;
if (money <=250);
cout<<"Sorry you cannot have an overdraft"
system("pause")
Two problems here ( unless I'm misreading the code ).
1. 'Magic' numbers are evil. If you want to have a a limit, set it at the top of your code like this:
const int nMaximumWithdrawal = 500;
Then if you want to change the value later, you can do so easily without introducing bugs.
2. I suspect this code is supposed to refer to the customers balance to check if it's an overdraft, instead of a predefined value.
Good luck !!!
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Hello there,
Watch out for this classic C++ mistake:
You code:
else if (mmchoice = 1);
should be:
else if (nmchoice == 1)
Note the semicolons should not be there and the double == sign.
The double == is comparing while the single = is assigning.
Art
|
|
|
|
|
hi
i need to know a way to convert CString variable to Hex char
afender
|
|
|
|
|
<br />
CString str = ...;<br />
int n = _ttoi(str);<br />
<br />
CString sHex;<br />
sHex.Format(_T("%X"), n);<br />
|
|
|
|
|
What do you mean?
If you want to 'dump' the contents of a CString as hex, you could do the following:
CString string;
for (int = 0; i < string.GetLength(); i++) {
#if defined UNICODE
printf("%04X",string[i]);
#else
printf("%02X",(unsigned)string[i]);
#endif
}
If your CString contains a hex value, and you want to convert it to an integer,
CString string = "1234ABCD";
int value;
sscanf(string,"%x",&value);
Software Zen: delete this;
|
|
|
|
|
how to find out in CListCtrl whether item's checkbox was selected or not?
|
|
|
|
|
|
I wrote MFC app that required displaying Unicode text in RichEdit and other Unicode stuff. I used VC7 and Unicode version of MFC. Under WinNT/XP all works fine. Is it possible to use Microsoft Layer for Unicode to avoid special adaptation of that app for Win9x/Me? I followed the instructions in MSDN, but my App still doesn’t work under Win9x, its main window does not appear. It seems to me my app has Unicode version of WinMain. How Layer for Unicode treat all this?
|
|
|
|
|
hi,
Win 9x does not support unicode itself, you must re-write the unicode functions yourself, and all functions/class export the normal char in stead
w-char but Inside in your own class/functions w_char could be used....
i think it is very hard to make your program real unicode support for win'9x
(perhaps you make a special resource file for translated texts,
win'9x has a good support of russian/baltic/other east-european languagues it self, but Asian Languages like chinese / japanese / koreoan / sanskriet is very poor)
dan o
|
|
|
|
|
Now i have another problem!
How can i display images in the picture control by pressing the same button?
i mean if i press the button once a bitmap to be displayed,if i press the button again another bitmap to be displayed..
Thanks again!
|
|
|
|
|
Maybe you can use Davide Calabro's CButtonST v3.8 (MFC Flat buttons)[^], which allows for what you want and much more.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
As I understand you want to change the bitmaps of the control on clicking a button.
You may do this by storing the bitmaps in HBITMAP array and sending the STM_SETIMAGE on each click after changing the bitmaps array counter.
This code may illustrate.
HBITMAP hBitmaps[4];
int index = 0
.
.
.
case IDC_YOURBUTTON:
index++;
index = index < 4 ? index : 0;
HWND hWnd = ::GetDlgItem(hDlg, IDC_MYPICTURE);
::SendMessage(hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmaps[index]);
.
.
.
note that we do not delete the current bitmap in the control as in the last post becaues we want to preserve the bitmaps to continue the switching.
|
|
|
|