|
You're appending the m_strET value to m_strMessage . Is this the member variable displayed in the dialog, or is it m_strET ? If it's the latter, that would explain why you only see one value.
Software Zen: delete this;
|
|
|
|
|
m_strMessage is the editbox that the user can see. m_strET is not visible, I use it as a temp.
I have found out by updating m_E20, so I can see what happens, and adding this to the code right bedore the "}" of my for: m_E20--;
I set the value in m_E20 to 10, as to have 10 throws, but when I push the button the value in m_E20 becomes 9; so it throws the dice only 1 time, not 10 times
Thanks, BF
|
|
|
|
|
I think I've figured it out. Here's your original code:
void CZmurfDICEDlg::OnD20()
{
int ret;
for(int k=0; k < m_E20; k++)
{
UpdateData(TRUE);
m_strET="";
srand((unsigned)clock());
ret=rand()%20+1;
m_strET.Format("%d ",ret);
m_strMessage=m_strMessage+m_strET;
}
UpdateData(FALSE);
} Calling UpdateData(TRUE) inside the loop resets all of the member values to whatever is on the screen, which clears out what you've been calculating in the loop. Also, you don't need to seed the random number generator each iteration of the loop. Try this instead:
void CZmurfDICEDlg::OnD20()
{
int ret;
UpdateData(TRUE);
srand((unsigned)clock());
m_strMessage="";
for(int k=0; k < m_E20; k++)
{
m_strET="";
ret=rand()%20+1;
m_strET.Format("%d ",ret);
m_strMessage=m_strMessage+m_strET;
}
UpdateData(FALSE);
} Using this logic, m_strET will display the last value calculated, and m_strMessage should display the list.
Software Zen: delete this;
|
|
|
|
|
Just as a side note: When you are posting more than one line of code, you can use the <pre>...</pre> tags to format it. It makes the code a lot easier to read. I think that's why I didn't notice the UpdateData(TRUE) call inside the loop before.
Software Zen: delete this;
|
|
|
|
|
Thanks a lot, that was it
Cheers, BF
|
|
|
|
|
|
You have to move the statement UpdateData(TRUE); outside the for loop. The value of the variable m_E20 is not updated when you come to the for loop. So the loop does not get executed.
So the correct way is
UpdateData(TRUE);
for(int k=0; k < m_E20; k++)
{<br />
m_strET="";
-----<br />
}<br />
UpdateData(FALSE);
|
|
|
|
|
Hi,
I want to use ST_SplitterWnd (http://www.codeproject.com/splitter/st_splitterwnd.asp). The right pane should be a CFrameWnd with a DialogBar and some views. Attached to the Dialog Bar is a CTabCtrl for switching between the views in the CFrameWnd. The problem now is, that a small part of one of the views is visible within the first view at the left upper corner.
When showing the other views (by clicking at the appropriate tab) and then going to the first view again, the problem is gone.
When I use a standard CSplitterWnd I don't have this effect.
What's wrong?
Thank's
#9370
-- modified at 7:41 Sunday 13th November, 2005
|
|
|
|
|
Off-hand, it sounds like an initial background painting problem.
You would probably be better off posting a message in the article's forum, since it sounds like a problem related to the article code.
Software Zen: delete this;
|
|
|
|
|
Hi Gary,
thank you for your reply but I already tried it in the article's forum - I got no answer yet.
#9370
|
|
|
|
|
Hi!!!
I'm an italian studentand I'm implementing an OPC XML DA Client using managed C++.
In the Write primitive, for each item I have to set the ItemValue as an istance of the Object class, like the OPC specification requires.
By Client interface I obtain a String. I have tried to obtain an Object by casting, but the response of the OPCserver was "E_BADTYPE", cause the OPCServer see a String*, not an Object*.
What can I do to obtain an Object (acceptable by OPCServer) from a String?
Maybe this is a stupid question, but I'm a beginner in the OPC World.
Thanks a lot.
Ninni Crisafi
|
|
|
|
|
I am new to using Bitmaps in my programs... As tutorial/practice I want to create a simple game, the graphics of which will be supplied by bitmaps, however loading and blitting the individual bitmaps to the window DC provides much flicker. I realize I need to implement some double buffering strategy, however, I am, as yet unable to do so.
The way I see it:
1. Create two compatible DCs. (intermediate and final)
2. Load and select the individual bitmaps to the intermediate DC.
3. BitBlt() then ecah to their proper position in the "final" DC
4. Load and select the "final" bitmap (the final DC) into the window DC
5. BitBlt() this resultant image to the screen.
I am assuming there is something I do not understand about the process, or step four above, specifically. I am unsure what.
The code:
BITMAP bm;
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
HBITMAP hbmOld;
HDC hdcMem = CreateCompatibleDC(hdc);
HDC hdcFinal = CreateCompatibleDC(hdcMem);
int loopX, loopY;
for (loopX = 0; loopX < 20; loopX++) {
for (loopY =0; loopY < 20; loopY++) {
hbmOld = (HBITMAP)SelectObject(hdcMem, LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(map.getMap(loopX, loopY))));
GetObject(LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(map.getMap(loopX, loopY))), sizeof(bm), &bm);
BitBlt(hdcFinal, loopX * 32, loopY * 32, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
}
}
hbmOld = (HBITMAP)SelectObject(hdcFinal, CreateCompatibleBitmap(hdcMem, 640, 640));
GetObject(CreateCompatibleBitmap(hdcMem, 640, 640), sizeof(bm), &bm);
BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcFinal, 0, 0, SRCCOPY);
SelectObject(hdcFinal, hbmOld);
SelectObject(hdcMem, hbmOld);
ReleaseDC(hwnd, hdcFinal);
ReleaseDC(hwnd, hdcMem);
EndPaint(hwnd, &ps);
|
|
|
|
|
Here's an old example that talks about eliminating flicker:
Flicker-Free Displays Using an Off-Screen DC
I would just try to get a flicker free example working using a simple color fill first. (use FillRect) Once you've got that down, replace the FillRect code with the code that draws your bitmaps.
"When you know you're going to eat crow, it's best to eat it while it's still warm." - Reader's Digest
|
|
|
|
|
Akilez wrote: HDC hdcFinal = CreateCompatibleDC(hdcMem);
Change hdcMem to hdc there - both mem DCs have to be compatible with the DC that's connected to the screen.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | NEW~! CP SearchBar v3.0 | C++ Forum FAQ
"Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!"
-- Rico Mariani, CLR perf guy
|
|
|
|
|
I want to access the basic port by using this
simple functions _inp and _outp which are used
in the TurboC compilers or say compilers for DOS.
In windows i tried to use them in my MFC programe
but there are Runtime errrors stating Unprivilaged
instruction .
I also tried to use the assmebly code for the same
but the same error is disaplayed .
can anyone suggest me any other option for this
thankin you
vikas
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I am afraid you are out of luck in the Windows world. Input and output instructions are privileged, which means that only device drivers are allowed to use them. The purpose of this is to protect system integrity and to let the operating system arbitrate access to the hardware, which is considered a shared resource.
If you are trying to control a specific piece of hardware, you should contact the manufacturer to see if they provide a Windows driver and interface software that you can use.
Software Zen: delete this;
|
|
|
|
|
You will need to create a miniport driver (.sys) that can map that memory and access that I/O. After that you can create a macro that uses the inp/outp syntax to call the miniport. See MSDN for more info on miniports.
|
|
|
|
|
vikas amin wrote: I want to access the basic port by using this
simple functions _inp and _outp which are used
in the TurboC compilers or say compilers for DOS.
What about simple Api like ReadFile and WriteFile
"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
|
|
|
|
|
I have used the IO library you can find at http://www.logix4u.net/inpout32.htm[^]
This allows your code to run on Windows 9x or XP. Works nicely!
As I recall, the documentation is a bit poor, for example, it is not clear that the input and output calls are 8-bit. (This may have been fixed by now.)
|
|
|
|
|
any help on how to manage the code in VC++
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
What do you mean by the term "manage"?
Software Zen: delete this;
|
|
|
|
|
vikas amin wrote: any help on how to manage the code in VC++
What about Visual Source Safe or CVS
"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
|
|
|
|
|
I am trying to activate a vertical scroll bar in a CGridCellRich control embedded in Chris Monder's CGridCtrl control. My use of ES_MULTILINE in the call to Create has the desired effect, but setting the WS_VSCROLL bit does not produce scrollbars.
m_RichEditTemp.Create ( WS_CHILD | ES_MULTILINE | WS_VSCROLL, CRect(0,0,0,0), this, IDC_RICHEDIT_TEMP);
Also, I tried calling ShowScrollBar from the control itself, but this has no appearent effect. Any suggestions would be appreciated.
Thanks,
Gil
|
|
|
|
|
hey guys,i am currently working on the media player project,
i am want have feature like capture the cd track by using directshow
and convert the track to mp3 into the harddrive
is it possiable by using Da Directshow?
thanks
|
|
|
|
|
If you have an MP3 encoder filter loaded the it should not be a problem.
|
|
|
|
|