|
Ummm... that's an awful lot of code to look through.
You might want to consider only posting the relevant pieces of code in the future. I'd doubt if anyone would read through that much.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I gave all the code, cuz I felt that it would be better for all to know exactly what was going on and I didn't wanna be told I didn't give enuf information!
Anyways, here are some snippets, then:
the main APP OnPaint() function.
void battleshit::OnPaint() {<br />
CPaintDC dc(this);<br />
<br />
CPen pen;<br />
pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 150));<br />
<br />
CBrush brush;<br />
brush.CreateSolidBrush(RGB(0, 0, 200));<br />
<br />
dc.SelectObject(&pen);<br />
dc.SelectObject(&brush);<br />
<br />
dc.Rectangle(0, 0, 400, 552);<br />
<br />
player->draw(&dc);<br />
computer->draw(&dc);<br />
}
and a single CELL draw code:
<br />
void CELL::draw(CPaintDC *pdc) {<br />
if (hilited) <br />
pdc->SelectObject(&hiliter); else<br />
pdc->SelectObject(&pen);<br />
<br />
pdc->SelectObject(&cellBrush);<br />
pdc->Rectangle(rect);<br />
<br />
CRect circle = rect;<br />
circle.left += 5;<br />
circle.top += 5;<br />
circle.right -= 5;<br />
circle.bottom -= 5;<br />
<br />
pdc->SelectObject(&pen);<br />
pdc->SelectObject(&pegBrush);<br />
pdc->Ellipse(circle);<br />
}<br />
a SHIP object draw code:
<br />
void SHIP::draw(CPaintDC *pdc) {<br />
if (hilited)<br />
pdc->SelectObject(&hiliter); else<br />
pdc->SelectObject(&pen);<br />
<br />
if (sunk())<br />
pdc->SelectObject(&sunkBrush); else<br />
pdc->SelectObject(&shipBrush);<br />
<br />
if (size != 5) {<br />
pdc->Rectangle(rect);<br />
} else {<br />
pdc->Rectangle(rect);<br />
<br />
if (hilited)<br />
pdc->FloodFill(location.x + (CELLSIZE / 2), location.y + (CELLSIZE / 2), RGB(0, 255, 255)); else<br />
pdc->FloodFill(location.x + (CELLSIZE / 2), location.y + (CELLSIZE / 2), RGB(0, 0, 0));<br />
<br />
if (vertical) {<br />
} else {<br />
}<br />
}<br />
<br />
pdc->SelectObject(&pegBrush);<br />
for (int c = 0; c < size; c++) {<br />
pdc->SelectObject(&pen);<br />
pdc->SelectObject(&pegBrush);<br />
}<br />
}<br />
and finally the BOARD object draw code:
<br />
void BOARD::draw(CPaintDC *pdc) {<br />
pdc->SelectObject(&pen);<br />
pdc->SelectObject(&boardBrush);<br />
<br />
pdc->Rectangle(rect);<br />
<br />
for (int y = 0; y < size; y++) {<br />
for (int x = 0; x < size; x++) {<br />
cells[x][y].draw(pdc);<br />
}<br />
}<br />
<br />
for (int ship = 0; ship < 5; ship++) {<br />
ships[ship].draw(pdc);<br />
}<br />
<br />
CRect tRect, sRect;<br />
tRect.left = rect.left - (CELLSIZE + CELLSPACING);<br />
tRect.top = rect.top - (CELLSIZE + CELLSPACING);<br />
tRect.right = rect.left + 300;<br />
tRect.bottom = rect.top + CELLSIZE;<br />
sRect = tRect;<br />
sRect.left += 2;<br />
sRect.top += 2;<br />
<br />
pdc->SetTextColor(RGB(0, 0, 0));<br />
pdc->SetBkMode(TRANSPARENT);<br />
pdc->DrawText(_T(title), -1, sRect, DT_SINGLELINE);<br />
pdc->SetTextColor(RGB(255, 255, 0));<br />
pdc->DrawText(_T(title), -1, tRect, DT_SINGLELINE);<br />
}<br />
Yyou will notice some lines of code that read if (hilited) { /*do hilite stuff*/ } else { /*do NON-hilite stuff*/ } . It seems that if I change the hilite value from true to false (or vice-versa) I have to invalidate the area for the change to take affect....this is what is causing the flicker!
One fella sed ..."You need to use a memory DC" - a what???
Perhaps I am just daft...but I did take a course (a 20,000 dollar course at that, altho the course wasn't JUST MFC)...so I should hope i know at least a little of what i am doing...hehe; the teacher was useless at helping me correct the flicker - told us (the whole class) to figger it out ourselves!!!
anyways, thanx for yer help guys! It really is appreciated, and please please forgive my previous LONG post...
ciao for now! JamRoll...
JamRoll@telus.net
http://jamroll.dyndns.org/
|
|
|
|
|
JamRoll wrote:
One fella sed ..."You need to use a memory DC" - a what???
Using a memory device context basically means that you do all your drawing to a bitmap held in memory, then at the end draw it to the screen with a BitBlt() call. Then whenever you redraw the window, don't erase anything (override OnEraseBkgnd() and do nothing) and just draw the new image over the top. That will give no flicker.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I see...can ya point me in the direction of a simple example of how to use a memDC? I found a thingy called CMemDC.h, but that's pretty intense stuff...i'm still mainly a beginner here...
ty again.
JamRoll
jamroll@telus.net
http://jamroll.dyndns.org/
|
|
|
|
|
JamRoll wrote:
I found a thingy called CMemDC.h, but that's pretty intense stuff...i'm still mainly a beginner here...
Using Keith's CMemDC class is much easier than doing it manually... That's the easiest you're gonna get
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi all .
I need to understand Digital Map File Format and show it in VC++ . I looked for it in web but I couldn't find any things.
Please Help me ?
Please Guide me ?
|
|
|
|
|
I am declaring a vector variable
vector<ciwapt5socket>m_RemoteInfo;
If try to use this another class(CIWAPT5Socket) it's
giving invalid indirection.why??
Here is the class code i am referring
((CIWAPT5Dlg*)m_Dlg)->pSocket = new CIWAPT5Socket(m_Dlg);
if(Accept(*((CIWAPT5Dlg*)m_Dlg)->pSocket))
{
LocalServerInfo *m_info;
*((CIWAPT5Dlg*)m_Dlg)->m_RemoteInfo->push_back(m_info);
MessageBox(NULL,"Connection Accepted","IWAPT5 Server",MB_OK;
}
|
|
|
|
|
The question is: how do youndeclare the vector, what does it contain LocalServerInfo or (LocalServerInfo *)
DavidR
|
|
|
|
|
I am declaring a vector variable
vector<ciwapt5socket>m_RemoteInfo;
If try to use this another class(CIWAPT5Socket) it's
giving invalid indirection.why??
Here is the class code i am referring
((CIWAPT5Dlg*)m_Dlg)->pSocket = new CIWAPT5Socket(m_Dlg);
if(Accept(*((CIWAPT5Dlg*)m_Dlg)->pSocket))
{
LocalServerInfo *m_info;
*((CIWAPT5Dlg*)m_Dlg)->m_RemoteInfo->push_back(m_info);
MessageBox(NULL,"Connection Accepted","IWAPT5 Server",MB_OK;
}
|
|
|
|
|
I have a doubt like,
when i used code like this for a dialog based application,in oninitdialog()
=========================================
CRect m_WindowRect;
GetWindowRect(&m_WindowRect);
CRgn m_Rgn;
m_Rgn.CreateRoundRectRgn (m_WindowRect.top,m_WindowRect.left,m_WindowRect.Width(),m_WindowRect.Height(),10,10);
SetWindowRgn((HRGN) m_Rgn, TRUE);
==============================================================
it is working fine,means the edges of the dialog box,little bit round shape, where as
if i used the same code in a SDI on initialupdate() it is not working,
so how to retrive that type of shape(edges is looks like a round shape) in sdi view also,
i am getting a problem like if i used the same code i am unable seeing the title bar.send reply soon asap.
in sdi iused like this
=======================================================
CRect m_WindowRect;
AfxGetApp()->m_pMainWnd-> GetWindowRect(&m_WindowRect);
CRgn m_Rgn;
m_Rgn.CreateRoundRectRgn (m_WindowRect.top,m_WindowRect.left,m_WindowRect.Width(),m_WindowRect.Height(),10,10);
AfxGetApp()->m_pMainWnd-> SetWindowRgn((HRGN) m_Rgn, TRUE);
===================================================
n.srinukumar
|
|
|
|
|
as title.
Can I do this?
WCHAR *strPtr1 = new WCHAR[10];
strPtr1 = L"123456";
LPWSTR strPtr2 = strPtr1;
if I do not delete strPtr1 and strPtr2 before redirect strPtr2 points to the other place, will it cause memory leakage?
e.g
strPtr2 = L"abcdef";
And there is any difference between
WCHAR *strPtr1 = new WCHAR[10];
and
LPWSTR *strPtr1 = new wchar_t[10];
?
Thanks
|
|
|
|
|
WCHAR *strPtr1 = new WCHAR[10];
strPtr1 = L"123456";
LPWSTR strPtr2 = strPtr1; Both pointers now point to the same array of 10 WCHAR 's. If you delete either pointer, the memory is returned to the heap, and neither pointer may be used to access the memory.
LPWSTR *strPtr1 = new wchar_t[10]; This will not compile. LPWSTR , which can be read as Long Pointer to Wide STRing, is defined as
typedef WCHAR FAR * LPWSTR; in the Windows headers. If you had written
LPWSTR strPtr1 = new wchar_t[10]; instead, this would work. Notice I removed the asterisk between LPWSTR and strPtr1 . LPWSTR is already a pointer. WCHAR and wchar_t are essentially equivalent, in that they refer to a 16 bit value used as a wide character.
Software Zen: delete this;
|
|
|
|
|
That's mean it is no difference between LPWSTR and WCHAR*?
|
|
|
|
|
The LP stuff is a throwback to the old Win16 days.
In Win16, you have two types of pointers, NEAR and FAR. A near pointer is only 16 bits wide and can only access 65k of memory. A far pointer is 32 bits wide and can access many megs of memory. (The upper and lower 16 bits of a FAR pointer usually overlap a few bits).
So, "FAR WCHAR *" in WIN32 is the same thing as "WCHAR *" since FAR doesn't do anything anymore. And since WCHAR is the same (or mostly the same) as wchar_t, then LPWSTR is the same as "wchar_t *". Also, LPCWSTR is the same as "const wchar_t *".
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
One can set a bookmark in the VC6 IDE, Alt-F2,
bookmark dialog. Such a bookmark seems to be
stable across projects. I can select all and
delete all. But, if I open an old project
then return to my current project via the
most recent project list -- say to look at
a backup copy or some older code -- then
all those old bookmarks are returned. I
have to clean it up again. Perhaps a good
feature; but not what I want!
I have searched the registry. I have deleted
.bsc files. But I don't find a way to clean
up my bookmark "history".
Can someone tell me a way to get rid of ALL
the old bookmarks. I want a clean slate.
NO bookmarks in any project (and I have lots
of old stuff laying about )
WedgeSoft
|
|
|
|
|
Dear All,
I am developing an application in VC++ Version 6.0 for Windows
2000/XP and want to have following functionality in it :
"Whenever the user right clicks on any drive, a menu is opened with
various options,and one of them is to Format the drive.I want to
replace the format window dialog box with my own custom dialog box."
So, is it possible to replace the windows format dialog box(which
comes when we try formatting a drive using right click) with our own
format box???
Is this functionality of windows is in form of a dll ? If it is so,
then i suppose we can replace that dll. (A case i know is that like
gina.dll contains the window that appears upon ctrl+alt+del and we can
replace this dll with our own). But i am not very clear on this issue.
Please suggest!
Regards,
Rohit
|
|
|
|
|
The format dlg is displayed by the API SHFormatDrive() , so in order to change that you'll need to hook that API. This is more complex than a simple shell extension.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
Dear all,
Question - I want to change the entry point of my program to some "MyFunction". I know that, it can be done by taking project Settings, Link tab, then Input section and specify the entry point.
But my requirement is to done it by code using any #pragma or any other preprocessor like that. Please help me.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
#pragma comment(linker, /entry:"MyFunction")
Bikram Singh
I believe we should all pay our tax with a smile. I tried - but they wanted cash.
|
|
|
|
|
Dear bikram,
Thanks a lot.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Hello Sir,
really i tried that->
#pragma comment(linker, /entry:"MyFunction")
but sad i didn't able to work it out.
pls help me in this.
thanks
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Unfortunately, that doesn't work. According to the MSDN, you can only use the /DEFAULTLIB, /EXPORT, /MERGE, /INCLUDE, and /SECTION linker options in a #pragma comment(linker,...) .
Software Zen: delete this;
|
|
|
|
|
hello i am working on a little information database for a game a friend of mine plays well everything is working smoothly but , i have been trying to make it so that when they get new information they can add it to a combobox through an editbox .. and the combobox will hold the information in the dropdown .. but i cant seem to get anything..
thank you for your time
|
|
|
|
|
nm i finaly got it needs a little tweaking but will have it shortly
thank you for your time
"Effort within the mind further limits the mind, because effort implies struggle towards a goal and when you have a goal, a purpose, an end in view, you have placed a limit on the mind"
|
|
|
|
|
hello,
i want to find the cpu usage time of a process.
i tried to use NtQuerySystemInformation in
ntdll.dll.
the syntax..
NTSTATUS NtQuerySystemInformation(
SYSTEM_INFORMATION_CLASS SystemInformationClass,
PVOID SystemInformation,
ULONG SystemInformationLength,
PULONG ReturnLength
);
i declared a pointer to function (the above func)
and tried to call it dynamically by using
LoadLibrary & GetProcAddress....
but, the program is giving a compilation error:
saying that -
NTSTATUS & SYSTEM_INFORMATION_CLASS are undeclared identifiers...
can anyone please help...
thank you..
|
|
|
|
|