|
Christian Graus wrote: Man, that stuff is hard on the eyes.
You reminded me of an interesting read I bookmarked a while back about word recognition and eye tracking...
The Science of Word Recognition[^]
|
|
|
|
|
Christian Graus wrote: Man, that stuff is hard on the eyes.
It's hard on one's mental health as well!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
|
Hi:
I have a variable of "map" type, which is defined as map<string, vector=""> table;.
How can I assign values to this table?
Normally, if "table" is defined as map<string, int="">.
We will simply:
this->table.insert(make_pair(string newString, int newInt));<br />
But this time, vector<> is not a simple variable but a complex one.
Any help is appreciated.
Thank you
|
|
|
|
|
Well, for starters, the vector needs it's own template arguements. Actually, for starters, you should check "Ignore HTML tags in this message (good for code snippets)", I had to view source to understand the question.
I always add to a map using table["string"] = 5; But, I'd imagine the purpose of a map to a vector is that you'd do this:
table["myKey"].push_back(myinstanceofwhatevertypethevectorholds);
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: myinstanceofwhatevertypethevectorholds
That's a nice variable name
|
|
|
|
|
I have a Piece of code that should only be able to run in one instance on each (LAN)networked computer. Idealy it should behave like Task Manager. i.e.: If one tries to start a second instance, control is transferred to the running instance. Anyone any idea how to do that?
LateNightsInNewry
|
|
|
|
|
This[^] article may help.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks Mark,
Very Helpfull, Much Appreciated, Will email you a Bottle of Wine
LateNightsInNewry
|
|
|
|
|
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Guys,
Please excuse this dumb question, but I am new to programming in Visual C++ 6.0 and I would like to know how to do the following. I have an array of bytes that it is provided by a Library (myLib.lib). This has a collection of functions that fetch an image from a camera, and provide me the pointer for the 1D array of RGB bytes of an image.
I am writing the application in Visual Basic 6.0 SP6. I want send a command via DLL to a VC++ generated DLL where:
1. when the function receives a command, the function displays a Dialog box
2. The dialog box has a picturebox and paints the array.
3. I saw visual C++ has all the gdi32.lib where Setbitmapbits() is included. However, I thought it was just as simple as using the function but apparently VC has quite a bit things to do in order to use the gdi32.dll or gdi32.lib
I have some experience writing C++ DLL libraries for Visual Basic using _stdcall type of functions. I figure I have to use an RC resource and I know simple Dialogs are available. The questions is how do I make that dialog show up when I call it from VB?
Does anyone know? Any help will be greatly appreciated by those of you who know C++ well. I know VB6 well, so if I can help send me your questions.
Regards,
rjrodrig@yahoo.com
VB on Steroids by VC++
|
|
|
|
|
rjrodrig wrote: how do I make that dialog show up when I call it from VB?
You will probably get a better answer if you ask this in the VB Forum.
|
|
|
|
|
I am using directsound.I used to compress ,translate and decompress sound using capXXX.But it is limited in some aspects,so I am changing to Directsound. But Directsound seems a little difficulty and complicated.So,I want want do something to encourage myself with some example.
If there has some example about this?I only want to capture,compress,and decompress sound data,but most of examples on the websource always about how to playback file streams.
|
|
|
|
|
kcynic wrote: But Directsound seems a little difficulty and complicated.So,I want want do something to encourage myself with some example.
In that case, maybe encourage yourself by getting it running well uncompressed.
Then when you're comfotable with that process (streaming audio samples out of and in to
DirectSound buffers) you can add compression.
For compression, a couple methods I know of are:
If you have a codec, you can feed the samples through that.
Included with Windows, there's the Audio Compression Manager[^]
Also, I believe DirectSound capture buffers will capture in a compressed format by using the
DSCBCAPS_WAVEMAPPED when creating the buffer and spcifying a format that maps to an Audio
Compression Manager codec. I'm not sure if playback buffers will map the other direction -
I've never tried it.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks,But would you like to tell me if the SDK have codec or not?
|
|
|
|
|
This link shows available codecs: http://support.microsoft.com/default.aspx?scid=kb;en-us;899113[^]
Depending on what compression manager you end up using, there should be APIs to list/choose
codecs. For example, acmFormatChoose() shows a dialog for selecting audio formats in the audio
compression manager.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I'm having a problem with memory device contexts and bitmaps in MFC. I've gotten to the point to where I can create and use them, but natrually they are all in black in white. See here:
http://img.photobucket.com/albums/v50/blackdwarf/piegraphcontrol.jpg[^]
With a CreateCompatibleDC(NULL) call, a monochrome bitmap gets created for and selected into the CDC. When I actually create my bitmap based off of that CDC, I'm stuck with the monochrome. So my question is, how do I initialize the bitmaps with color outside of OnPaint when I can't just use CPaintDC?
Here is some of the code...
Creating the two bitmaps without a CPaintDC (where I think the problem is):
BOOL CPieGraph::Create(CWnd* pParentWnd, const RECT& rect, UINT nID, DWORD dwStyle )
{
BOOL OverallSuccess = FALSE;
BOOL CreateResult = FALSE,
TextDCResult = FALSE,
PieDCResult = FALSE;
int SelectText = 0, SelectPie = 0;
CreateResult = CWnd::Create(CPIEGRAPH_CLASSNAME, _T(""), dwStyle, rect, pParentWnd, nID);
TextDCResult = TextMemDC.CreateCompatibleDC(NULL);
PieDCResult = PieMemDC.CreateCompatibleDC(NULL);
SelectText = m_textBitmap.CreateCompatibleBitmap(&TextMemDC, 250, 20);
SelectPie = m_pieBitmap.CreateCompatibleBitmap(&PieMemDC, 300, 300);
OldtextBitmap = TextMemDC.SelectObject(&m_textBitmap);
OldpieBitmap = PieMemDC.SelectObject(&m_pieBitmap);
TextMemDC.SetBkColor(RGB(255,255,255));
PieMemDC.SetBkColor(RGB(255,255,255));
if((CreateResult == TRUE) && (TextDCResult == TRUE) && (PieDCResult == TRUE) && (SelectText != 0) && (SelectPie != 0))
{
OverallSuccess = TRUE;
ControlRect = rect;
}
else
OverallSuccess = FALSE;
return OverallSuccess;
}
And OnPaintDC:
afx_msg void CPieGraph::OnPaint()
{
CPaintDC dc(this);
CDC ControlMemDC;
CBitmap ControlBitmap;
CBitmap* OldBitmap = NULL;
ControlMemDC.CreateCompatibleDC(&dc);
ControlBitmap.CreateCompatibleBitmap(&ControlMemDC, 300, 360);
OldBitmap = ControlMemDC.SelectObject(&ControlBitmap);
ControlMemDC.SetBkColor(RGB(255,255,255));
if(UpdateNeeded == true)
{
RedrawPieText(TextMemDC);
RedrawPieChart(PieMemDC);
ControlMemDC.BitBlt(0, 0, 250, 20, &TextMemDC, 0, 0, SRCCOPY);
ControlMemDC.BitBlt(0, 25, MainPieGraph.radius * 2,
MainPieGraph.radius * 2, &PieMemDC, 0, 0, SRCCOPY);
UpdateNeeded = true;
}
dc.BitBlt(ControlRect.left, ControlRect.top, 250, 320, &ControlMemDC, 0, 0, SRCCOPY);
ControlMemDC.SelectObject(OldBitmap);
}
|
|
|
|
|
Don't know an awfull lot about the issues, but it appears to be at first sight to be a problem about loss of information.It would appear to me that you first create a monochrome bitmap from a source, which you select into the CDC. At that stage the Die is cast as far as the CDC is concerned. The Monochrome bitmap is all it knows about. The CDC has built a Monochrome picture which it knows your Device can display. All Colour Info has been discarded. If at a later stage you want the Bitmap in colour, you have to start again from scratch in the same or another CDC, This time indicating yont to keep the colour. Mind you,to do so you could recycle most of the code. Just leave an indication somewhere about what way you want it, Monocrome or Colour. A Device Context is a Uniform Construct that Converts things like bitmaps etc into something your Hardware can display. (That's the way device-independence is Implemented).
Hope this is Usefull.
LateNightsInNewry
|
|
|
|
|
To add to LateNightsInNewry's reply...
To fix it...
When you call CreateCompatibleBitmap(), you should use the screen or paint DC, not the memory
DC. The memory DC you created with CreateCompatibleDC() is the one with a monochrome bitmap
selected into it. If you create a bitmap compatible with that, it will also be monochrome.
Outside of OnPaint, you can get a screen DC with
::GetDC(0)
or something like
CDC ScreenDC;
ScreenDC.CreateCompatibleDC(0);
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks, both of you. I think it'll work. I'll try it tommorow when I wake up.
|
|
|
|
|
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Actually I just got a cup about 30 minutes ago. Unfortunatly, the problem still remains. I tried using GetDC:
CDC* ScreenDC = NULL;
CreateResult = CWnd::Create(CPIEGRAPH_CLASSNAME, _T(""), dwStyle, rect, pParentWnd, nID);
TextDCResult = TextMemDC.CreateCompatibleDC(NULL);
PieDCResult = PieMemDC.CreateCompatibleDC(NULL);
ScreenDC = GetDC();
ASSERT(ScreenDC == NULL);
SelectText = m_textBitmap.CreateCompatibleBitmap(ScreenDC, 250, 20);
SelectPie = m_pieBitmap.CreateCompatibleBitmap(ScreenDC, 300, 300);
ReleaseDC(ScreenDC);
At first the assert statement wasn't in there and I just got black and white, then I put it in and I got a debug assertation on the same line, indicating that ScreenDC was null, and that GetDC didn't do the job. Any idea why?
|
|
|
|
|
Well the assert statement was wrong...it should have been ASSERT(ScreenDC != NULL), but it is still not rendering color for some reason. Fonts, brushes, and pens work fine, just not color.
|
|
|
|
|
CoffeeAddict19 wrote: but it is still not rendering color for some reason.
Hopefully my modified post below will help
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
CoffeeAddict19 wrote: indicating that ScreenDC was null
Is Create() failing? Never mind, I see you fixed the ASSERT
I steered you wrong with the CreateCompatibleDC, sorry
*EDIT* I DID show you a way to do what you were already doing though :)
This should work from anywhere:
CWindowDC ScreenDC(0);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&ScreenDC, 20, 20);
BITMAP bitmapstruct;
bitmap.GetObject(sizeof(BITMAP), &bitmapstruct);
You'll see in the BITMAP struct, the format matches the screen format.
Try this:
CreateResult = CWnd::Create(CPIEGRAPH_CLASSNAME, _T(""), dwStyle, rect, pParentWnd, nID);
CWindowDC ScreenDC(0);
TextDCResult = TextMemDC.CreateCompatibleDC(&ScreenDC);
PieDCResult = PieMemDC.CreateCompatibleDC(&ScreenDC);
SelectText = m_textBitmap.CreateCompatibleBitmap(&ScreenDC, 250, 20);
SelectPie = m_pieBitmap.CreateCompatibleBitmap(&ScreenDC, 300, 300);
Mark
-- modified at 14:54 Thursday 31st May, 2007
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|