|
|
Thank you so much
|
|
|
|
|
Hi,
I have a Arrow bitmap which has a White background and a Yellow Arrow
The BackGround of My Rich Edit is Gray RGB(125,125,125)
I would like the background of the Yellow Arrow to Match the background of My CRichEdit
I looked at some code from article on The CodeProject By Raja Segar entitled
"Drawing TransParent Bitmaps with ease"
and it seemed to do something close to what I want
I figured I didn't have to make the code that generic rather
I could Load the Bitmap and then create a mask bitmap with a text of white and background of Gray "OR" Orignal Bitmap and get what I went
Aprarently not
below is part of the Code
CBitmap *bm = new CBitmap;
bm->LoadBitmap((UINT) IDD_BITMAP);
CDC dcmask;
dcmask.CreateCompatibleDC(NULL);
BITMAP bm_struct;
bm->GetBitmap(&bm_struct);
CBitmap bmask;
bmask.CreateBitmap(bm_struct.bmWidth,bm_struct.bmHeight,bm_struct.bmPlanes,bm_struct.bmBitsPixel,NULL);
dcmask.SelectObject(&bmask);
dcmask.SetTextColor(RGB(0,0,0));
dcmask.SetBkColor(RGB(125,125,125));
CDC dcarrow;
dcarrow.CreateCompatibleDC(NULL);
dcarrow.SelectObject(bm);
dcarrow.BitBlt(0,0,bm_struct.bmWidth,bm_struct.bmHeight,&dcmask,0,0,SRCPAINT);
dcmask.DeleteDC();
dcarrow.DeleteDC();
Afterwards I used OleCreateStaticfromData using the bitmap handle to Display the bitmap
would anyone know why I didn't get a gray background for the yellow arrow
thankx
|
|
|
|
|
Hi guys what i want to do is to show some data in a ClistCtrl column like the following:
________________________________________
stuff |$ 434.55 |
----------------------------------------
stuff2|$ 22,333.55 |
----------------------------------------
stuff2|$ 86.55 |
----------------------------------------
have the dollar sign at the left side, and the number be always at the right side, can someone point me how to do this?? maybe calculing the size of the text and compare it to the cell rect and to some math there? but how how do you get the size of the text?, i remember seeing a function for that but i don't remember the name of it, or if you have an another suggestion please
|
|
|
|
|
manchukuo wrote: but how how do you get the size of the text?
GetTextExtentPoint32[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks CPallini that is the one i was looking for, so there is no easy way to achieve what i need? or i will have to do all the mungle jumble that i already wrote?
|
|
|
|
|
I would go with the mungle jumble (i.e. sorry, I don't know an alternative).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Have you tried GetNumberFormat() to properly insert the commas and decimal? Then just prefix a '$' and a number of spaces to the resulting string.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Have you tried GetCurrencyFormat[^]?
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Hello All!
I want to read a number from CMD [For example: 1234]. Then put each of its components in an array [ For example: a[0]=1, a[1]=2, a[2]=3, a[3]=4 ].
Could anyone help me with my duty?!
The case is urgent!
Thanks for your further cooperation.
|
|
|
|
|
in most programming languages a string is an array of characters;
and in ASCII (and Unicode) the digits 0-9 have consecutive values
(actually 0x30-0x39, but you don't need to know that since you could do (int)(mychar-'0') ).
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Try this code.
It reads a number from CMD [For example: 1234].
Then puts each of its components in an array - digitArray[3]=1, digitArray[2]=2, digitArray[1]=3, digitArray[0]=4
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
int digit=0,digitInput=0;
int digitArray[4]={0},digitn;
void getIntKey(void)
{
digitArray[0]=0;
digitArray[1]=0;
digit=0;
digitInput=0;
while((digit<4))
{
if (kbhit())
{
digitInput=getch();
if ((digitInput>47) && (digitInput<59))
{
digitArray[digit]=(unsigned char)digitInput-48;
digit++;
}
if (digitInput==13) { digitn=digitArray[0]; break; }
}
}
if (digitInput!=13) digitn=digitArray[3]*1+digitArray[2]*10+digitArray[1]*100+digitArray[0]*1000 ;
printf("\n%i\n\n",digitn);
}
int main()
{
system("color 1F");
printf("This program by TopCoder requires you to input 4 digits \n ");
printf("Input Digits (ex. 1=0001 , 1234=1234) \n ");
printf("\nInput Digits >");
getIntKey();
printf("\ndigitArray[3]=%d \n",digitArray[3]);
printf("digitArray[2]=%d \n",digitArray[2]);
printf("digitArray[1]=%d \n",digitArray[1]);
printf("digitArray[0]=%d \n",digitArray[0]);
printf("\n%i\n\n",digitn);
return 0;
}
..
|
|
|
|
|
That was co0l, realy!!
But, is it possible to wait until Enter pressed to diagnose the number of digits? And then the program dynamicaly tunes itself in order to put these digits into the char array which its dimension is defined by the number of digits, the user entered?
|
|
|
|
|
Yes, digit++ can sets the dimension.
Lets say you want to limit the user input to a 9 figure number or 100,000,000,
just set while((digit<4)) to be 9 or whatever and then write the code to process it.
eg.. digitn=digitArray[3]*1+digitArray[2]*10+digitArray[1]*100+digitArray[0]*1000 to digitArray[n]*100000000
This method is clunky .
|
|
|
|
|
Now it is just clunky
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
int digit=0,digitInput=0;
int digitArray[10]={0},digitn;
void getIntKey(void)
{
digitArray[0]=0;
digitArray[1]=0;
digit=0;
digitInput=0;
while((digit<9))
{
if (kbhit())
{
digitInput=getch();
if ((digitInput>47) && (digitInput<59))
{
digitArray[digit]=(unsigned char)digitInput-48;
digit++;
printf("%d",digitInput-48);
}
if (digitInput==13) { digitn=digitArray[0]; break; }
}
}
switch(digit)
{
case 0:
case 1:
digitn=digitArray[0]*1 ;
break;
case 2:
digitn= digitArray[1]*1 +digitArray[0]*10 ;
break;
case 3:
digitn= digitArray[2]*1+digitArray[1]*10 +digitArray[0]*100 ;
break;
case 4:
digitn=digitArray[3]*1+digitArray[2]*10+digitArray[1]*100+digitArray[0]*1000 ;
break;
case 5:
digitn=digitArray[4]*1+digitArray[3]*10+digitArray[2]*100+digitArray[1]*1000+digitArray[0]*10000 ;
break;
case 6:
digitn=digitArray[5]*1+digitArray[4]*10+digitArray[3]*100+digitArray[2]*1000+digitArray[1]*10000
+digitArray[0]*100000;
break;
case 7:
digitn=digitArray[6]*1+digitArray[5]*10+digitArray[4]*100+digitArray[3]*1000+digitArray[2]*10000
+digitArray[1]*100000 +digitArray[0]*1000000;
break;
case 8:
digitn=digitArray[7]*1+digitArray[6]*10+digitArray[5]*100+digitArray[4]*1000+digitArray[3]*10000
+digitArray[2]*100000 +digitArray[1]*1000000+digitArray[0]*10000000;
break;
case 9:
digitn=digitArray[8]*1+digitArray[7]*10+digitArray[6]*100+digitArray[5]*1000+digitArray[4]*10000
+digitArray[3]*100000 +digitArray[2]*1000000+digitArray[1]*10000000 +digitArray[0]*100000000;
break;
}
printf("\n%i\n\n",digitn);
}
int main()
{
system("color 1F");
printf("DigitsIntoArrayComponents 3.1 by TopCoder \n ");
printf("Max Input is 8 Digits ( . 99,999,999) \n ");
printf("\nInput Digits >");
getIntKey();
printf("\ndigitArray[7]=%d \n",digitArray[7]);
printf("digitArray[6]=%d \n",digitArray[6]);
printf("digitArray[5]=%d \n",digitArray[5]);
printf("digitArray[4]=%d \n",digitArray[4]);
printf("digitArray[3]=%d \n",digitArray[3]);
printf("digitArray[2]=%d \n",digitArray[2]);
printf("digitArray[1]=%d \n",digitArray[1]);
printf("digitArray[0]=%d \n",digitArray[0]);
printf("\n%i\n\n",digitn);
return 0;
}
...
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
The most cplusplusy way of doing this is to just copy the input from std::cin into your array of characters:
std::vector<char> text;
std::copy( std::istream_iterator<char>( std::cin ), std::istream_iterator<char>(), std::back_inserter( text ) );
You'd have to press CTRL-Z to terminate the input though.
If I've misread what you want and you really want an array of integers, one per digit in the number you have to do a bit of conversion instead of a copy:
std::vector<int> digits;
std::transform( std::istream_iterator<char>( std::cin ), std::istream_iterator<char>(), std::back_inserter( digits ), []( const char c ) { return int( c - '0' ); } );
If your compiler doesn't support Lambda functions (For VC++ it's VC++ 2010 or for gcc it's version 4.3 or later) then it's a bit fiddlier but you need a function object instead of the Lambda function. (The Lamba's the final parameter to the std::transform call, []( const char c ) { return int( c - '0' ); ).
Cheers,
Ash
|
|
|
|
|
bijan.8k wrote: I want to read a number from CMD...
Do you mean the command line?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hallo,
I try to open the html return from an Internet URL, for example http://leavemusic.de/live/leavemusic/index.php, and I want to get the html code in a CString. What is the best way to do it? It does not work with CFile for me.
Thank you!
|
|
|
|
|
Have you tried URLDownloadToFile()?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
If you don't want to use the function David suggested and if you've got time to experiment I can wholeheartedly recommend using cURL[^] for what you're trying to do. It's very customisable, flexible and portable. It's also got a bit of a clunky C handle based interface only it's programmer could love but for the sort of thing you're after it's not too bad. It took me about 4 hours of reading and playing to get a small file downloader working with it.
If you know how to use sockets then you could just open a socket on the remote computer, send and HTTP get and read everything between the opening <HEAD> tag and the closing </BODY> tag. I'd only recommend this method if you're already comfy with network programming otherwise the small details might get a bit much.
Cheers,
Ash
|
|
|
|
|
I encountered a hard question:
#include <windows.h>
#include <time.h>
int main(int argc, char* argv[])
{
LPCTSTR fileName = "\\\\192.169.3.9\\tempdir\\MYFILE.TXT";
HANDLE hFile;
DWORD dwError;
time_t nowTick = time(NULL);
hFile = CreateFile(fileName, // open MYFILE.TXT
GENERIC_READ, // open for reading
FILE_SHARE_READ, // share for reading
NULL, // no security
CREATE_ALWAYS, // overwrite existing
FILE_ATTRIBUTE_NORMAL | // normal file
FILE_FLAG_OVERLAPPED, // asynchronous I/O
NULL); // no attr. template
if (hFile == INVALID_HANDLE_VALUE)
{
dwError = GetLastError();
printf("error:%x, diff:%d\n",dwError, time(NULL) - nowTick);
return 0;
}
CloseHandle(hFile);
return 0;
}
Question:
1.Why does the function CreateFile block a long time when the path specified by the variable fileName is not exist?
2.If i does not expect the function CreateFile block a long time, does it have a better solution?
3.what's the best solution of accessing the file on the net?
I am a c++ programer!
It's cheerful to cooperate with you!
|
|
|
|
|
the API is accessing the file via networking, so you got a long timeout.
C++ programmer are writing for lenghtly operations threads.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
...and go for a coffee or play some game during.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
thats what i do. or listening to some music.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|