I dont really mind putting them into a zip and uploading, anyways to get back on topic this is what I got so far, it works okay but there are a few problems.
It browses okay trough the buffer, however when you press the up arrow button then you will have to press the down arrow button twice to display the next command, and vice versa with the up arrow button, when you press the down arrow key, you will have to press twice the upper arrow to get it display the right buffer.
I also noticed that it is crashing at a point when you browse trough the buffer for a while, I think I am forgetting some part, anyone have an idea?
Code:
if(wParam == VK_UP) {
if(!Commands[ComLast]) {
/* No item available! */
SetWindowText(hWnd, "");
return FALSE;
}
else {
SetDlgItemText(GetParent(hWnd), IDC_COMMAND, Commands[ComLast]);
}
/* Move the retrieval index up one. */
ComLast = ComLast - 1;
/* Loop to end if required. */
if (ComLast == -1) ComLast = 15;
}
else if(wParam == VK_DOWN) {
if(!Commands[++ComLast]) { /* Increase here ? */
/* SetWindowText(hWnd, ""); */
/* No item available! */
return FALSE;
}
else {
SetDlgItemText(GetParent(hWnd), IDC_COMMAND, Commands[ComLast]);
}
if (ComLast == 16) ComLast = 0;
}
This is the VK_RETURN part:
Code:
if(wParam == VK_RETURN) {
char *buf;
int buflen = GetWindowTextLength(hWnd);
if (buflen == 0) return FALSE;
if((buf = malloc(sizeof(char) * ++buflen)) == NULL) {
/* No Memory Space */
return FALSE;
}
/* Note: We have to get the text before we delete it. */
GetWindowText(hWnd, buf, buflen);
SetWindowText(hWnd, "");
/* Free the old memory pointer if it exists. */
if (Commands[ComIndex]) free(Commands[ComIndex]);
/* Store the buf memory pointer in the Command array. */
Commands[ComIndex] = buf;
/* Set retrieval slot to last stored item. */
ComLast = ComIndex;
/* Move storage slot to next slot in array. */
ComIndex++;
/* Loop to start if at end of array. */
if (ComIndex == 16) ComIndex = 0;
return TRUE;
}