|
How to use them and which on earth to pick ?
Thank you , anyway!
Hello World!
|
|
|
|
|
This topic was discussed previously
The chosen One
|
|
|
|
|
which page?
Thank you very much!
Hello World!
|
|
|
|
|
Please see this[^] and this[^] thread. They will answer your question.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Hi,
does anyone know a possibility to mark code (.exe .dll) as unpageable!
to prevent windows from paging these code out of the memory.
Tanks,
Eddie
|
|
|
|
|
VirtualLock(), but if you have to ask then almost certainly you shouldn't be using it.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
So does that mean that until a person learns how to use a function or an API, they shouldn't be using it? I'm curious how one goes about learning about something without first using it?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Not at all, you've over generalized. I said that about VirtualLock in particular not about API's in general.
Page locking memory is one of those things that is very seldom a good idea. The appropriate times for doing it usually occur in device drivers, and they use a different, kernel mode, API to accomplish this. Mostly people think they'll page lock parts of their application to 'improve performance' and that almost never works. Trust the memory manager to trim the working-set appropriately.
Off hand, the only legitimate reason I can think of for locking pages in a user-mode app is to prevent plaintext from being written to the pagefile in a crypto scenario, and I'm not positive it even guarentees that as expected.
Hence, unless you already know a _lot_ about how the Windows VM system works, you shouldn't be tampering with it, and if you don't know about VirtualLock then clearly you don't know enough about the VMM.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
I am trying to call menu from dialog. That menu's ID is ID_MYMENU.
When you click on this button, it will do certain thing. what i
am trying to do is to call this ID_MYMENU from dialog and do the
same thing as when you click on the ID_MYMENU. I was thinking
to use function like SendMessage(ID_MYMENU,**,**) something like this.
Please help!
Shin
|
|
|
|
|
You don't need to call the menu from a button.
If you want more than 1 GUI object to be handled by the same code, then you should just edit the message maps to point to the same function.
|
|
|
|
|
If your dialog box is modal, it could be dangerous to activate a command of the application. Anyway, here's the syntax:
CMainFrame *pFrame = AfxGetApp()->m_pMainWnd;
pFrame->SendMessage(WM_COMMAND, ID_MYMENU);
Beware that with SendMessage, the call won't return before the execution of the command.
Silence Means Death
Stand On Your Feet
Inner Fear
Your Worst Enemy
|
|
|
|
|
Thank you very much. in this way, I can save a lot of
time. however, I will be carefull with those point you
mensioned.
Thanks, again.
Shin
|
|
|
|
|
My pleasure
Silence Means Death
Stand On Your Feet
Inner Fear
Your Worst Enemy
|
|
|
|
|
I am in the midst of making a FlexGrid editable in my dialog app.
For that I am creating a floating edit box same as dimesions of a cell and then placing the box at a specific cell.
What is the correlation between coordinates
Finally i need to place the edit control(say pEdit) at a cell location using
pEdit->SetWindowPos(0,x,y,width,height);
how do I calculate x , y width and height
I tried this
int y=m_flex1.GetCellTop();
int x=m_flex1.GetCellLeft();
int width=m_flex1.GetCellWidth();
int height=m_flex1.GetCellHeight();
But values seem goofy
I need to convert twips to pixels .
so I need
1. Conversion between twips and pixels
2. Final values of x ,y , width and height !
Please help
Engineering is the effort !
|
|
|
|
|
I started doing this as an experiment for one of my projects but then I aborted the idea. Download whatever stuff I wrote from this link [^] but let me warn you that I put it there for you and I will remove it as soon as you are done downloading it. I am running out of space, that's why. Let me know how it works for you.
// Afterall, I realized that even my comment lines have bugs
|
|
|
|
|
Here's what I've done in my project:
long lCellTopTwips = m_Grid.GetCellTop();
long lCellLeftTwips = m_Grid.GetCellLeft();
long lCellWidthTwips = m_Grid.GetCellWidth();
long lCellHeightTwips = m_Grid.GetCellHeight();
long lCellTopPixels;
long lCellLeftPixels;
long lCellWidthPixels;
long lCellHeightPixels;
TwipsToPixels(lCellTopTwips,
lCellLeftTwips,
lCellTopPixels,
lCellLeftPixels);
TwipsToPixels(lCellWidthTwips,
lCellHeightTwips,
lCellWidthPixels,
lCellHeightPixels);
m_Grid.GetWindowRect(&rect);
ScreenToClient(rect);
pEdit->MoveWindow(rect.left + lCellLeftPixels,
rect.top + lCellTopPixels,
lCellWidthPixels,
lCellHeightPixels);
#define TWIPS_PER_INCH (1440.0f) //A twip is 1/1440 of an inch (from MSDN)
//////////////////////////////////////////////////////////////functionstart//
void GUI_MntTreeDlg::TwipsToPixels(long lTwipsX,
long lTwipsY,
long &lPixelsX,
long &lPixelsY)
//
// DESCRIPTION: Convert from Twips (screen independent units) to pixels
// A twip is 1/1440 of an inch (from MSDN)
//
// WARNINGS:
//
// ERRORS:
//
//////////////////////////////////////////////////////////////functionend//
{
CDC* pDC = this->GetDC();
long lPixelsPerInchX = pDC->GetDeviceCaps(LOGPIXELSX);
long lPixelsPerInchY= pDC->GetDeviceCaps(LOGPIXELSY);
this->ReleaseDC(pDC);
lPixelsX = (float)lTwipsX / TWIPS_PER_INCH * (float)lPixelsPerInchX;
lPixelsY = (float)lTwipsY / TWIPS_PER_INCH * (float)lPixelsPerInchY;
}
//////////////////////////////////////////////////////////////functionstart//
void GUI_MntTreeDlg::PixelsToTwips(long lPixelsX,
long lPixelsY,
long &lTwipsX,
long &lTwipsY)
//
// DESCRIPTION: Convert from pixels to Twips (screen independent units)
// A twip is 1/1440 of an inch (from MSDN)
//
// WARNINGS:
//
// ERRORS:
//
//////////////////////////////////////////////////////////////functionend//
{
CDC* pDC = this->GetDC();
long lPixelsPerInchX = pDC->GetDeviceCaps(LOGPIXELSX);
long lPixelsPerInchY= pDC->GetDeviceCaps(LOGPIXELSY);
this->ReleaseDC(pDC);
lTwipsX = (float)lPixelsX * TWIPS_PER_INCH / (float)lPixelsPerInchX;
lTwipsY = (float)lPixelsY * TWIPS_PER_INCH / (float)lPixelsPerInchY;
}
|
|
|
|
|
the edit box is shown intially at cell 1,0, when I made this
long lCellTopTwips = m_Grid.GetCellTop();<br />
long lCellLeftTwips = m_Grid.GetCellLeft();<br />
long lCellWidthTwips = m_Grid.GetCellWidth();<br />
long lCellHeightTwips = m_Grid.GetCellHeight();<br />
<br />
long lCellTopPixels;<br />
long lCellLeftPixels;<br />
long lCellWidthPixels;<br />
long lCellHeightPixels;<br />
<br />
TwipsToPixels(lCellTopTwips,<br />
lCellLeftTwips,<br />
lCellTopPixels,<br />
lCellLeftPixels);<br />
<br />
TwipsToPixels(lCellWidthTwips,<br />
lCellHeightTwips,<br />
lCellWidthPixels,<br />
lCellHeightPixels);<br />
<br />
<br />
m_Grid.GetWindowRect(&rect);<br />
ScreenToClient(rect);<br />
pEdit->MoveWindow(rect.left + lCellLeftPixels,<br />
rect.top + lCellTopPixels,<br />
lCellWidthPixels,<br />
lCellHeightPixels);
a function called MoveOperation()
and on the OnClickEvent for the Grid I called this function . I find that the edit control is nt shown !!!
Engineering is the effort !
|
|
|
|
|
I'm not sure I understand exactly what you did. If I understand correctly, you call a function called MoveOperation() in onclickEvent and perform the required operations for the move.
That seems correct, however, there is something I didn't include in the original post because I thought it was obvious. Add this at the end of your MoveOperation():
pEdit->ShowWindow(SW_SHOW); //Show the edit box
pEdit->SetFocus(); //Set focus to the edit box
pEdit->SetSel(0,-1,FALSE); //Select the text in the edit box
|
|
|
|
|
I am trying to make a game that can 'think'. This is a tic-tack-toe game. I was wondering how to make it. The basic layout uses arrays. The only thing I need to do is to make the computer 'Think'. Please reply with anything it doesn't matter what. I would appreciate it if they helped. Thanks.
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
There was a thread on the same topic just a few days ago... going back and , looking at it[^] might help
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
|
|
|
|
|
Do a google on Tic-Tac-Toe algorithms - there is a lot of data out there!
My solution relies on "brute-force" because the grid is only 3 x 3. So an if-then tree can be constructed to handle every possible condition in the game with little effort.
There are only 3 possible starting positions - a corner, a non-corner/non-center, and the center.
There are a max of 5 moves per player.
If you assign every space on the grid a number that is twice the number before it, you'll end up with:
1 2 4
8 16 32
64 128 256
There are only 16 different ways that an opponent can have 2 out of 3 squares - and those 16 ways can be expressed as the sums of those numbered squares.
You can test for a condition where the opponent can win on the next turn by comparing the sums of the opponents rows, columns and diagonals (and subtracting the value of the computer's squares) against those 16 values.
|
|
|
|
|
Hi,
computer thinking games, oftenly use what is called 'heuristic' functions (search google for tic-tac-toe heuristic).
This means, that if you have a matrix (which represents the tic-tac-toe board game) then each cell receive a number defining the importancy of it. for example as we all know the most powerful cell in the tic-tac-toe board game, is the center cell (2,2). so you can give this cell the amount of 100 (arbitrary).
for starters thing of the values you can give for the cells. next when design the computer movement, search for the best value to move to (the highest is the best, the lowest is the worst)....
In computer science B.A every course that deals with A.I (artificial intelligence) explains heuristic. you also need to learn how to build a tree from the data and perform searches on that tree like (BFS - best first search) and others.....
hope i helped you to begin
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
if u did it can u send it to me on hisham86@aucegypt.edu i should do it by trees
|
|
|
|
|
hello everyone i am still new to VC++ and i have been trying to make a form of easy start program nothing big lol but what i am having trouble with is this
for example: make a button that says dragons well when you click on that button it will bring up a web page that has misc dragons on it
or
let it bring up a jpeg that you have on the computer
thats what i am having trouble with
there might have been a tut on this if so then i have over looked it
thanks
nate
"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"
|
|
|
|
|
It sounds like you are having difficulty mapping an event to a function.
(I make that assumption because event handling is the greatest common denominator of "click a button and pull up a web page" and "click a button and load a JPEG from disk")
An "event" is anything that a user can do with their input devices (typically mouse and keybopard) that results in your program being told something has happened (other events are generated by the system as well).
Windows informs your code that an event has happened by sending "Messages". Messages contain data that defines the name for the message and additional data that is pertinent to that specific message.
"Handle"ing that event is simply writing code that is executed in response to an event.
MFC passes information to your classes as events happen. For example - when a user double-clicks their mouse, Windows sends a message that tells your program that the mouse was double-clicked. For the double-click message, the additional data are the coordinates of where the mouse click was.
To get your program to respond to a button being clicked, you need to follow these steps:
1) Create an App in App-Wizard - make it Dialog based for learning. It is easier.
2) Go to the Resource view and look at your main dialog.
3) Add a button from the tool palette.
4) Edit that button's properties - name it IDC_DRAGON. For it's caption, enter whatever you want
5) Type Ctrl-W to open Class Wizard
6) Make sure the class selected is the Dialog box class for your main dialog
7) Highlight the button's ID (IDC_DRAGON) in the Object IDs listbox
8) You'll see 2 messages in the "Messages" listbox that Windows recognizes for that type of highlighted object
9) Double-click on the BN_CLICKED message
10) You will see a small dialog that opens and asks you for the name of the function that will Handle that Event (clicking the button). You can usually just use the default. Click OK.
11) What you have just done is add an empty Message Handler for code that will be executed when a user clicks that button.
12) Notice that the text in the Messages listbox is now bold for the message BN_CLICKED. This means that Class Wizard has created a Handler for that Message
13) Look at the Member Functions listbox - you should see that the function name you entered (or accepted as the default) for the handler for the BN_CLICKED Message for the IDC_DRAGON object is highlightd.
14) Double-click that highlighted function and you will be taken to your source code - right at the spot where you need to write the code to handle that event.
15) Just to verify that you are handling the event - write the following code where Class Wizard positions you:
MessageBox("Dragon Button", "BN_CLICK Handler");
16) If you do it correctly, you will see the message box when you click the Dragon button
If this explanation was too simplistic, I apologize. It sounded like you needed help in handling events.
If you complete steps 1-16 correctly, then you will be ready to write the actual code you need to respond to a button click.
|
|
|
|