|
LateNightsInNewry wrote: DEF Files seem to have gone out of fashion.
See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I have seen your See Here, and read all that, What it does not explain is the Syntax of Forwarding a Function. DEF Files seem to have gone out of fashion to the extent that the only help the IDE gives, is, (in my version anyways), that All you can do in a DEFFile, can be done better by using command line options for the Linker/ Compiler. I know that not to be the case, but hence my question.
LateNightsInNewry
|
|
|
|
|
I want to draw a bitmap,(droughts for example)on dialog,
at mouse's coordinate when it's pressed !
Could you help me !
Lgx
|
|
|
|
|
This is Not a simple Problem, and a Full solution for your own custom application will resort to a long list of API's
The Outline would be as follows:-
-Create a Dialog with a Bitmap Resource in it.
-Assign a Bitmap
-In the Dialog, implement the OnPaint Method to paint the Bitmat,taking account of where you want it painted.
-Use the WM_MOUSEBUTTON messages to capture the mouse when it is clicked over the immage
-Use the WM_MOUSEMOVE messages to track the mouse, and to issue WM_PAINT messages to keep the image following the mouse.
(The Latter is not as simple as it seems)as you will discover.
You will also see that the easier UpdateWindow Call does not work for this in a dialog, it only sends a WM_PAINT after you finally release the mouse button.
As I said, Not a simple task, there is not a single API available that does the lot, Also, not a task for beginners(Choose something simpler, i.e. Move the Image to where the mouse was released, without dragging), at the same time, we all have to start somewhere. The prize is, that when you master this, you have learned a lot about the Windows API.
Let me know how you get on
Regards
LateNightsInNewry
|
|
|
|
|
thank you !
i am studying to build a program that play chess(or gomoku) over LAN !
i will build it step by step !
there are very much so program !
when you click mouse on coordinate(x,y) on the board,
drought (stone) will paint !
i want also do that !
have you ever done that ?
Lgx
|
|
|
|
|
No, I have never build a program that play chess(or gomoku) over LAN !.
However, I see that you are taking on a very complex task. If I where you, I would break the task up into a number of DLL's
Seeing that you want to play some sort of game over a network, you will need somewhere where the score is kept, i.e. a server for the purpose of the game.(This need not be the Network Server). The way I would write this would be, Game server Software, which keps track of the various games being played, and which would need no other interface than something to keep track of players and scores, and Client software, which monitors the Game moves, and communicates same with the Game server. The game Server in this case would be the final arbitor on the legality, or otherwise, of any moves.In this scheme of things, you need to think first of exchange protocols for this type of information, implementation of game rules, etc, etc.
I would be inclined at the development stage at least, to implement the clients as a console program, i.e. a Chess Move is implemented by a client by typing something like "E2->E4!, and getting back an error message like: "Err 4087: Sorry, The Piece on Field E2 is a Knight, For a Knight the move E2->E4 is Illegal". After you have this Up,Going and Debugged, you can write some beautiful graphics to simulate the game, using essentially the same messaging service to the server.
Hope this is Usefull,
LateNightsInNewry
|
|
|
|
|
http://www.codeproject.com/internet/renju.asp[^]
thank you for sincere advice !
sorry for my bad English !
the game that i want buid that don't need game server !
for example, game :HalfLife,age of empire,...
all is only a program !
when a person run game program, that person can establish
that is server program, other persons who want join in will click "show all game" and see a game that they want play with and therefore this program is client !
score and other information is stored temporality, when game over, that information is lost.
the game that i want buid is don't need in real time mode
it's turn move by move !
especial, i want that : when game is being played, everybody can see all game is playing, opening(that game is created but nobody join in)
the this game have many characteristic similar to multiuser chat program !
the link i wrote upper is renju game program over LAN
i hope that you will for me many your advice !
see you !
|
|
|
|
|
I think you are doing this the wrong way.
First you don't really to handle the WM_MOUSEMOVE message unless you are drawing to a particualr size or dragging a bitmap across the screen.
Second, you don't need to draw the bitmap to the exact position of the mouse for the game you have mentioned.
Consider this. you have a checkerboard, each square being 20x20 pixels, you have a checker piece 15 pixels in diameter. now, if the user clicks the board at say 5,5 of a square (upper left corner), and you draw the piece (from the center) at these coordinates, the piece will overlap into the neighbouring squares.
Here's your solution. create a map of your board (an array holding position of each square). Check for user mouse clicks, when user clicks, check the position against those in your array to find the square. Then draw the bitmap to the center of that square.
This type of game is called a "tile based game", a search on google will yield many results. Also if you are keen to start coding games, I would recomend a library called Allegro, which enables you to handle bitmaps and user input very easily.
|
|
|
|
|
of course as you say about overlap
the thing that i want say is how to paint a bitmap when mouse click event happened and location that bitmap is drawed is belong to coordinate of mouse !
i tryed many code but if i minimize the dialog of program,
then nothing to see!
void CGomokuDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if((nFlags & MK_LBUTTON)== MK_LBUTTON)
{
//get Device context:
CClientDC dcc(this);
//draw pixel:
dcc.SetPixel(point.x,point.y,RGB(0,0,0));
}
CDialog::OnMouseMove(nFlags, point);
}
void CGomokuDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this); // device context for painting
CBitmap bitmap;
bitmap.LoadBitmap (IDB_BITMAP1);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap* pOldBitmap = dcMem.SelectObject(&bitmap);
CPen pen1(PS_SOLID,16, RGB(255,100,0));
dc.SelectObject(&pen1);
//dc.StretchBlt(100, 130, 20, 20, &dcMem,
// 0, 0, 20, 20, SRCCOPY);
dc.MoveTo(0,0);
dc.LineTo(30,400);
CDialog::OnLButtonDown(nFlags, point);
}
-- modified at 22:14 Sunday 9th April, 2006
|
|
|
|
|
See the following link
<a href="http://www.codeproject.com/buttonctrl/hoverbutton.asp" rel="nofollow">http:
Knock out "T" from CAN'T
You 'CAN' if you think you 'CAN'
|
|
|
|
|
I have a spoiled problem with OpenFileDialog in .net 2003, if the number of files inside a folder was too much, I can't see anything to select. Does anybody have any experience with this problem?
Let's come together to know more!
|
|
|
|
|
LRESULT CALLBACK KeyboardHookProc( int code,WPARAM key, LPARAM lParam)
{
(1) if (((DWORD)lParam & 0x40000000) &&(HC_ACTION==code))
{
...
(2) GetKeyboardState(ks);
...
(3) ToAscii(key,scan,ks,&w,0);
}
...
}
Please, could somebody explain in simple terms what the meaning of lines 1..3 is. I've been doing my nut trying to figure it out, and good Net explanations are thin on the ground. Your help is deeply appreciated.
EvScott
|
|
|
|
|
Have you looked up those functions in MSDN? MSDN has a pretty plain explanation that I can parrot here but it is easier for you to look it up yourself. If you need any clarification then post a more specific question.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Could you post the Complete Code, rather than the bits you seem to consider important. It is actually quite simple, and all well documented. Just, the snippet you show leaves out the reasons for calling the API's
LateNightsInNewry
|
|
|
|
|
Hi,
I am using Visual Studio .NET 2003. I'd like to know if there is some way to run a memory leak checker (like CodeGuard in Borland C++).
Thank you,
Rafael Fernández López.
|
|
|
|
|
install Bounds Checker
never say die
|
|
|
|
|
Hi all,
could any one help me with an STL problem? the code below throws an assertion error [_SCL_SECURE_VALIDATE(this->_Mycont != NULL); from vector.h, line 117] when executing line #5 only after executing line #4. Line #5 works fine as long as the 'if' block is not entered. I am using MSVC 2005 and did not have this problem with the previous version. Is there any change to the way STLs are handled now? Thx everyone,
Ralf.
1 ivFKey = szvCopy.begin();
2 while (ivFKey != szvCopy.end()) {
3 if (*ivFKey == szFKey) //delete all equal; what's left are 0-catches
4 szvCopy.erase(ivFKey);
5 ++ivFKey;
6 }
ralf.riedel@usm.edu
|
|
|
|
|
|
ivfKey = szvCopy.erase(ivFKey)
|
|
|
|
|
I am coding an application that displays a couple of CRgn objects. Each CRgn is filled using anoher brush. So I need two arrays to store the CRgn and CBrush objects.
I also need to save to a file the arrays so when I open the application again I can continue to work with those objects.
It would like to use CArray because I can use m_rgnArray.Serialize(ar) to save the array to a file...
But my program doesn`t work as expected and I get a lot of "assertion failed" messages.
This is how I declared the variables:
<br />
CArray <CRgn, CRgn> m_rgnArray;<br />
CArray <CBrush, CBrush> m_brushArray;
Is this the way I should use CArray with CBrush and CRgn? Is it even possible to use CArray with CBrush and CRgn?
|
|
|
|
|
You can't persist GDI objects like that. You'll need to store the coordinates of the regions and attributes of the brushes, and recreate the GDI objects later.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
<i>LRESULT CALLBACK KeybrdHook( int code,WPARAM key, LPARAM lParam)
{
if (((DWORD)lParam & 0x40000000) &&(HC_ACTION==code))(<b>1</b>)
{
...
GetKeyboardState(ks);(<b>2</b>)
...
ToAscii(key,scan,ks,&w,0);(<b>3</b>)
}
...
}</i>
Could someone please put me out of my misery and explain the lines numbered 1..3. It's driving me potty. There's not a lot of useful, simple to understand explanations on the Net. Many thanks.
EvScott
|
|
|
|
|
EvScott wrote: Could someone please put me out of my misery and explain the lines numbered 1..3.
1) The bits in lParam are being ANDed with 0x40000000. If that result is non-zero and code equals HC_ACTION , the next two statements are executed.
2) The function GetKeyboardState() is being called. When finished, ks is a 256-byte array that will receive the status data for each virtual key.
3) The function ToAscii() is being called. This will translate the specified virtual-key code and keyboard state to the corresponding character or characters.
EvScott wrote: There's not a lot of useful, simple to understand explanations on the Net.
Actually, quite the opposite is true.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
void foo1()
{
foo2();
}
void foo2()
{
foo3();
}
void foo3()
{
STACKFRAME64 frame;
DWORD_PTR programcounter;
programcounter = getprogramcounter();
memset(&frame, 0x0, sizeof(frame));
frame.AddrPC.Offset = programcounter;
frame.AddrPC.Mode = AddrModeFlat;
frame.AddrFrame.Offset = framepointer;
frame.AddrFrame.Mode = AddrModeFlat;
StackWalk64(, , , &frame, , NULL, , , NULL);
}
DWORD_PTR getprogramcounter()
{
DWORD_PTR programcounter;
__asm mov AXREG, [BPREG + SIZEOFPTR]
__asm mov [programcounter], AXREG
return programcounter;
}
My assumption about the above code snippet is that foo3 obtain the address of "getprogramcounter()(program counter?)" by calling getprogramcounter(), and it is
from there the foo3 begin to trace back. So in this case getprogramcounter()->foo3()-2()->1()? But What's the relation between foo3()'s getprogramcounter()'s address and its frame pointer, as the "frame.AddrPC.Offset" and "frame.AddrFrame.Offset" indicate.Doesn't the frame pointer alone enough to get its caller's stack frame? why use program counter? How the StackWalk64 deal with them. What exactly happened?
|
|
|
|
|
Having moved back to Visual Studio 2005, it is now bombarding me with warnings about ISO C++ deprecation of certain functions (such as strdup and stricmp). Most of these warnings disappear when I tell it to mind it's own business with _CRT_SECURE_NO_DEPRECATE. However, is it advisable to actually do what Microsoft say and switch everything over to the new versions of the functions?
|
|
|
|
|