|
Do mean size of dialog ? What about GetClientRect() ?
|
|
|
|
|
Basically what I'm trying to do is add the functionality to let the user select a JPEG background image for my game, as eye candy. MFC has functions for handling bitmaps but nothing for JPEGs or other image formats. I'd like to load a JPEG and convert it to a bitmap so that I can blit it as necessary. What is the best way to do this? I'd rather do it without tacking on a huge library to my program, if possible.
|
|
|
|
|
Look at the GDI+ library.
If you are aiming only at Windows XP, it ships with the DLL.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
You can use of CImage class for load jpg file.
|
|
|
|
|
CoffeeAddict19 wrote: I'd like to load a JPEG and convert it to a bitmap so that I can blit it as necessary.
If you use GDI+ it's pretty simple...
Gdiplus::Bitmap SrcBitmap(L"C:\\Images\\MyJPEG.jpg", FALSE);
HBITMAP hBitmap;
SrcBitmap.GetHBITMAP(Gdiplus::Color(0xFF,0xFF,0xFF), &hBitmap);
|
|
|
|
|
|
CoffeeAddict19 wrote: I'd like to load a JPEG and convert it to a bitmap so that I can blit it as necessary. What is the best way to do this? I'd rather do it without tacking on a huge library to my program, if possible.
http://www.codeproject.com/bitmap/extendedbitmap2.asp
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Re
|
|
|
|
|
Hello,
I need to write a simple program that does the following:
- Accept voice from microphone
- Determine the volume of the voice (programatically)
- Increase or decrease a variable based on the volume of the voice from the microphone.
I will appreciate any help in this regard. Please a source code supplied with it will also be very good.
Thanks alot.
Commickey
|
|
|
|
|
OK, you have some demo's in the msdn, you have to search for SAPI (Speech API).
I don't remember where I saw that exactly, but searching for SAPI must help you. if you don't find it, pleaqse tell it to me, I suppose that in a couple of days I'll be able to send something that I must have stored in some backups at home.
Hope this helps.
|
|
|
|
|
Hello Stuart,
I still cannot find it... can you help again as you said?
Greetings,
Commickey
|
|
|
|
|
You could search here on CP for "record sound" for some source code.
Mark
|
|
|
|
|
hello,
pls find me out why code is not work for solitaire game...
Thanks in advance.pls..
here is code:
#include<iostream>
using namespace std;
/*****CLASS PLAYING CARD*****/
class PlayingCard
{
private:
int rank;//integer 1-13
int suit;//integer0-3
char color;//red('r') or black('b')
public:
PlayingCard(int,int);
PlayingCard();
void display();
~PlayingCard();
const static int diamond;
const static int heart;
const static int spade;
const static int club;
};
/***** CLASS MAKING PILE OF CARDS*****/
class PileofCards
{
private:
PlayingCard *pile;//pointer to array of playing cards
int top;//last element added to array
int size;//no. of cards in pile
int position;//position of pile amongst others
public:
PileofCards(int,int);
~PileofCards();
PlayingCard Peek();
PlayingCard Remove();
void display();
void Add(PlayingCard);
bool IsEmpty();
bool IsFull();
};
/***** CLASS DECK OF CARDS*****/
class Deck
{
private:
PlayingCard *deck[52];
int size;
public:
Deck();
int getSize();
bool IsEmpty();
PlayingCard getCard(int i);
void Display();
PlayingCard removeCard(int i);
~Deck();
};
/*****CLASS SOLITIRE*****/
class Solitire{
private:
Deck deckofCards;
PileofCards shuffled;
public:
Solitire();
void shuffle();
void display();
};
Solitire::Solitire():shuffled(52,1)
{}
/*****INITIALIZING*****/
const int PlayingCard::diamond=0;
const int PlayingCard::heart=1;
const int PlayingCard::spade=2;
const int PlayingCard::club=3;
/*****CONSTRUCTOR PLAYING CARD*****/
PlayingCard::PlayingCard(int X,int Y)
{
rank=X;
suit=Y;
if(Y==0 || Y==1)
{
color='r';
}
else if(Y==2 || Y==3)
{
color='b';
}
else
{
cout<<"invalid suit,object not created"<<endl;
}
}
*****constructor="" overloaded*****=""
playingcard::playingcard()
{
}
="" *****destructor*****=""
playingcard::~playingcard()
{
}
="" pile="" of="" cards*****=""
pileofcards::pileofcards(int="" x,int="" y)
{
size="X;
position=Y;
pile=" new="" playingcard[size];
top="-1;//empty" array
}
=""
pileofcards::~pileofcards()
{
delete="" []="" pile;
}
="" *****is="" empty*****=""
bool="" pileofcards::isempty()
{
if(top="=-1)
{
cout<<"pile" empty"<<endl;
return="" true;
}
else
{
return="" false;
}
}
="" full*****="" pileofcards::isfull()
{
if(top="=size-1)
{
cout<<"sorry" cannot="" add="" since="" is="" full"<<endl;
return="" true;
}
else=""
{
return="" false;
}
}
="" *****adding="" playing="" card="" to="" the="" pile*****=""
void="" pileofcards::add(playingcard="" x)
{
if(!isfull())
{
pile[top+1]="X;
top++;
}
}
/*****REMOVING" from=""
playingcard="" pileofcards::remove()
{
if(!isempty())
{
top--;
}
return="" pile[top+1];
}
="" *****peeking="" top="" pileofcards::peek()
{
return="" [top];
}
="" *****display....playing="" card*****="" playingcard::display()
{
cout<<rank<<"="" "<<suit<<"="" "<<color<<endl;
}
="" deck*****=""
deck::deck()
{=""
int="" j="0;
for(int" i="1;i<=13;i++)
{
deck[j]=new" playingcard(i,playingcard::spade);
j++;
}
for(int="" k="1;k<=13;k++)
{
deck[j]=new" playingcard(k,playingcard::diamond);
j++;
}
for(int="" l="1;l<=13;l++)
{
deck[j]=new" playingcard(l,playingcard::heart);
j++;
}
for(int="" m="1;m<=13;m++)
{
deck[j]=new" playingcard(m,playingcard::club);
j++;
}
int="" size="52;
}
/*****DESTRUCTOR"
deck::~deck()
{
if(!isempty())
{
for(int="" deck[i];
}
}
}
else=""
{
delete="" deck;
}
}
="" *****get="" size*****="" deck::getsize()
{
return="" size;
}
="" empty....deck*****="" deck::isempty()
{
if(getsize()="=0)
{
return"
return="" false;
}
="" *****getcard*****="" deck::getcard(int="" j)
{
return="" *deck[j];
}
="" *****display....deck*****="" deck:display()
{
for(int="">display();
}
}
/*****REMOVE...DECK*****/
PlayingCard Deck::removeCard(int i)
{
PlayingCard temp;
temp=getCard(i);
delete deck[i];
if(!IsEmpty())
{
for(int j=i;j<size;j++)
{
deck[j]=deck[j+1];
}
}
size--;
return temp;
}
="" *****shuffle*****=""
void="" solitire::shuffle()
{
int="" i;=""
while="" (!deckofcards.isempty())
{
i="rand()%deckofCards.getSize();"
="" cout<<"remove="" card="" \n";
shuffled.add(deckofcards.removecard(i));
}
}
="" *****display...solitire*****="" solitire::display()
{
if(!shuffled.isempty())
{
shuffled.display();
}
}
="" *****display...pile="" of="" cards*****="" pileofcards::display()
{=""
int="" i="0;
while(i<=top)
{
pile-">display();
i++;
pile++;
}
cout<
|
|
|
|
|
|
Sorry for that.. Thanks for remind me..
when I ran that code .. I got three error.. might be it from Deck..
Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 2 error C2063: 'Deck::deck' : not a function
Warning 3 warning C4154: deletion of an array expression; conversion to pointer supplied
|
|
|
|
|
Now everything is ok!No error anymore and I can run the program.
But it not work coz of warning.And if I debug the program,it said "Debug Assertion Failed!"and with "Expression:_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)"
Here is part of code:
[pre]Deck::~Deck()
{
if(!IsEmpty())
{
for(int i=0;i
|
|
|
|
|
|
I think error comes from destructor..mean warning!
Deck::~Deck()
{
if(!IsEmpty())
{
for(int i=0;i{
if(deck[i]!=NULL)
{
delete deck[i];
}
}
}
else
{
Code:
delete [] deck;
}
}
|
|
|
|
|
Hi,
with the help of MSDN I wrote my own little (pure) Windows Service, that doesn't do anything. I also implemented the ability to install/uninstall this service in the service database. My problem now is, that if I want to start that service from the system control in windows it crashes with a well known error message like this: "The instruction at 0xnnnnnnn referenced memory at 0xnnnnnnn. The memory could not be written."
I then wrote a simple logging-function, which prints the status information about my service to a file. And when I look at this file it seems that all is correct. All things are initialized and so on. And I also get to that point where the service's main function takes place, that means I get to the point where the real work of the service should take place. But as I said before, the service crashes while trying to start it up. That's a little strange to me. Maybe someone encountered a similar problem before or can give me some hint or help. That would be very nice. I know this description is a little bit vague, but it's not that easy because I can't figure out WHERE my service crashes. That's in fact my problem
Ah I forgot to mention, that I am using WinXP. Maybe that's important...
|
|
|
|
|
maybe posting your code will help...
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.
|
|
|
|
|
You can debug your service, and this is the best way to understand what happens.
Install the service with own process and interact with desktop, then place somwehere in code (in control dispatcher, or even service main) a DebugBreak call.
Go in admin tools/services, start the service; when the service will hit the DebugBreak call will invoke debugger, and you have now the chance to enter in Visual C++ debugger and check step by step the troubled piece of code.
|
|
|
|
|
Mh... I made a new project for my windows service and placed my real application code in there, and what shall I say.. it works perfectly. I just made some refactorings to my original windows service code... don't know why it works now. Anyway thank you for your help. I will remember that tip with the debugging.
|
|
|
|
|
When I use this control (AMSCurrencyEdit for example) I don't see the dialog from the class view and intellisense in that dialog.
The project compiles and builds OK, but i´d like to have intellisense in that dialogs.
Any solution for that?
it´s the journey, not the destination that matters
|
|
|
|
|
The intellisense is not very safe... some times it disappears.
First of all copy the entire folder of the project as a backup.
If I do not remember it bad, you should close Visual Studio, delete the .clw file and then try to reopen that project and try to go to the class wizard, as it will fail to locate that file, then you'll be asked to generate it again.
Select all the files in that project again and then try it. The intellisense should work.
PS: I've been a lot of time without touching the Visual C++ environment so this is from some rusty place in my brain... please remember to make the backup previously.
Hope this helps.
|
|
|
|
|
Thanks for your fast response!!!!
Unfortunately, I'm using VS2005. There's no .clw file.
And the problem is exactly with that component.
I change the name from CAMSCurrencyEdit to CEdit, save the project, and the dialog appears in class view, I change it again to CEdit and it dissapears.
It's not a big deal, but it's annoying.
it´s the journey, not the destination that matters
|
|
|
|
|
uuups... sorry, I'm beginning to be a dinosaur... I hope to be able to switch to VS2005 this year 2007...
ErnestoNet wrote: It's not a big deal, but it's annoying.
It always becomes annoying...
Well, I hope that somebody that will know better than me the VS2005 environment will be able to help you soon.
Good luck.
|
|
|
|