|
I have created a MFC single document application on VC++ 6.0 on a Win98 machine. I have done some testing on WinXP machines and it does not work correctly. I have included in stdafx.h the line
#define _WIN32_WINNT 0x0502
but it still does not work. Any help is greatly appreciated.
Brad Jennings
|
|
|
|
|
Oh, I forgot to mention that the program is multi-threaded. It doesn't seem to have any problems until a new thread is created.
Brad Jennings
|
|
|
|
|
Nevermind, it wasn't my program. My F8 key was sticking. Thanks.
Brad Jennings
|
|
|
|
|
Hi !
I'm writing a heap mangement functions namely Alloc and Free. An array of 4096 character is simulated as the heap. The main progam which has been written call Alloc 60% of the time and Free 40% of the time. The heap management is implemented by the linked-list. The algorithm to choose the page is first fit. The Alloc is passed in the number of bytes to be allocated. The Free function takes in the pointer at the begining of the chunk to be allocated.
Here is what i've attempt at it. I define a linked-list structure with *next is the pointer to the next node, size is the size in byte of how big the chunk is.
<br />
<br />
#include <windows.h><br />
#include "ssHeap.h"<br />
<br />
<br />
typedef struct _HEAP_STRUCT<br />
{<br />
DWORD size;<br />
struct _HEAP_STRUCT *next;<br />
}HEAP_STRUCT;<br />
<br />
<br />
HEAP_STRUCT *front;<br />
<br />
HEAP_STRUCT *temp, *prevNode;<br />
HEAP_STRUCT *node;<br />
<br />
<br />
<br />
char HeapSpace[4096];<br />
LPVOID beginOfTheHeap;<br />
<br />
void ssInit(void)<br />
{<br />
<br />
front = new HEAP_STRUCT;<br />
beginOfTheHeap = malloc(sizeof(HeapSpace));<br />
front = (HEAP_STRUCT*)beginOfTheHeap;<br />
<br />
front->next = NULL;<br />
front->size = 0;<br />
<br />
node = new HEAP_STRUCT;<br />
node->next = NULL;<br />
node->size = 0;<br />
<br />
<br />
};<br />
<br />
<br />
LPVOID ssAlloc(LONG nBytes)<br />
{<br />
HEAP_STRUCT *alloc = new HEAP_STRUCT;<br />
int allocated = false;<br />
<br />
while(nBytes % 8 != 0)
nBytes++;
<br />
<br />
if(front->next == NULL)
{<br />
<br />
node = new HEAP_STRUCT;
node->next = NULL;
node = front + nBytes;
<br />
<br />
front->size = nBytes;
front->next = node; <br />
return node;<br />
}<br />
<br />
<br />
<br />
while(front->next != NULL)<br />
{<br />
long freeSpace = ((int)front->next - (int)(front + front->size))/sizeof(char);
<br />
if( freeSpace> nBytes)
{<br />
<br />
while(freeSpace != nBytes)
{<br />
freeSpace = freeSpace / 2;
}<br />
<br />
node = new HEAP_STRUCT;
node = front + front->size;
node->size = nBytes;<br />
node->next = front->next ;
front->next = node;
alloc = node;
<br />
allocated = true;
}<br />
else <br />
{<br />
front = front->next;<br />
}<br />
}<br />
<br />
<br />
if(allocated)
return LPVOID(alloc);<br />
else
return NULL;<br />
<br />
};<br />
<br />
<br />
void ssFree(LPVOID p)<br />
{<br />
<br />
if(front == (HEAP_STRUCT*)p)
{<br />
front->size = 0;<br />
}<br />
else<br />
{<br />
prevNode = new HEAP_STRUCT;<br />
temp = new HEAP_STRUCT;<br />
<br />
<br />
while(front->next->next != NULL)<br />
{<br />
prevNode = front;
<br />
if(front->next ==(HEAP_STRUCT*)p)<br />
{ <br />
temp = front->next->next;<br />
prevNode = temp;<br />
delete front->next;<br />
}<br />
<br />
front->next = front->next->next ;
}<br />
<br />
}<br />
};<br />
<br />
Any constructive comment is highly appreciated!!
Regard,
|
|
|
|
|
Probably lots of time is lost in finding a chunk of the wanted size. This used to be a known problem in C run time libraries, that's why many people wrote their own memory management module.
A good idea is to prepare 'pools' of predefined sizes (e.g. multiples of 8) and manage lists of vectors in each of the pools.
If your application then requests e.g. 15 bytes, you round it up to the next multiple of 8 (16 in this case) and then go to the pool of 16 bytes. If it's empty, you allocate space for e.g. 10 chunks of 16 bytes. The next time you need 16 bytes (>9, <=16), it will be much faster.
Of course you need to foresee additional list-pointers in your vector of 10 chunks of 16 bytes to store information about which chunk is already handed out to the application, which one is free, what the size is, ...
Enjoy life, this is not a rehearsal !!!
|
|
|
|
|
Hi! The following values, which are greater
front = 0x003223d8
front->next = 0x00323118
Thanks, i have not clue which one is greater nor what they means! The only thing i know is that they are virtual address of a process. !!
Another thing is if i take
front->next - front
what does it give me???
Thanks
|
|
|
|
|
the numbers are too complicated: if u ask 1 and 3, which is "greater", i know the answer.
front->next - front is really meaningless except u do special research.
don't stick on those kind problems when u start to learn c++, or u will get lost.
includeh10
|
|
|
|
|
|
|
Those are hexadecimal numbers, base 16. That is what the 0x prefix means. Each digit can be 0-9 or a-f, where a-f represent decimal 10-15. So 3223d8 is less than 323118.
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
How to disable the taskbar name of any process
|
|
|
|
|
suresh_sathya wrote:
How to disable the taskbar name of any process
Make the following changes in your CWinApp derived class's InitInstance() :-
m_pMainWnd->ShowWindow(SW_HIDE);
m_pMainWnd->ModifyStyleEx(WS_EX_APPWINDOW,WS_EX_TOOLWINDOW);
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
The two lines in bold are the newly added lines.
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
hello:
my question is: we know the modal dialog dont deal with WM_PAINT message
but when i have a button on a modal dialog to deal with a large data,how can
i refesh the dialog?i have used following code:
MSG msg;
if (!::PeekMessage(&msg.NULl,0,PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
in the for loop;but it is useless;who can tell me why?
-----------------------------
Mr.Whelk
-----------------------------
Zhuhai City ,Guangdong ,China
|
|
|
|
|
So you think a modal dialog box doesn't process WM_PAINT messages ? You think wrong.
How low can you go ? (MS retrofuck)
|
|
|
|
|
(1) Your assumption about painting in modal dialogs is wrong. Modal dialogs do receive the WM_PAINT message.
(2) As for your other issue, you can start a worker thread so that your dialog and it's controls (including this particular button of yours) will remain receptive to keyboard and mouse messages.
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
hello,
I have the following problem,
float medium(float queueinput)
{
float queueout;
if ((queueinput>60)&&(queueinput<65))
queueout=(0.5/5)*(queueinput-60);
return (queueout);
}
When I execute it, it give me the warning:
"=": conversion from 'double' to 'float', possible loss of data
Does anyone know what's wrong inside it?
THX!!!
|
|
|
|
|
Numbers are double, by default. To avoid this warning, you can either disable it (#pragma warning...), or more carefully tell the compiler you are using floats : 0.5 --> 0.5f, 5 --> 5.0f, ...
How low can you go ? (MS retrofuck)
|
|
|
|
|
wong1907 wrote:
queueout=(0.5/5)*(queueinput-60);
(0.5/5) evaluates to a double-precision value, thus when multiplied bu your float, the result is a double. I usually use doubles and forget about float (I do numerical analyses that may be significant out to 20 decimal places or so). If you are set on using the smaller float, try:
float medium(float queueinput)
{
float queueout;
if ((queueinput>60)&&(queueinput<65))
queueout = static_cast < float > ((0.5/5)*(queueinput-60));
return (queueout);
}
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
Any reason why you are using float instead of double ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i need to execute a dos app1, and the dos app1 executes another app2.
i want to hide app1 but not hide app2.
(normally both are visible).
i try CreateProcess function, but if hide app1, app2 is invisible also.
i have a program (no code), the program can do that, so i know it is possible, but i have no idea with the tech.
any hints and guesses will be a help.
thanks in advance
includeh10
|
|
|
|
|
|
thanks, mate,
i will try ShellExecuteEx, hope it works.
my problem is a little bit more complex than this: i need re-direction from the dos app1 also, really headache.
includeh10
|
|
|
|
|
I need two things in my C column adding function:
1. Make it so its nullable
2. Dont demand that it be a required field.
All I know right now is:
m_pTable->Columns->Append(lpstrFieldName, (enum DataTypeEnum) Type, nLength);
How can I modify this to get what I want. They are just adding a column with Append. Apparently ADOX has a column property called Nullable, but I;d have to do something like:
ColumnA.Nullable(TRUE);
But I dont know how to get the columnA. What is it that the append can tell me about the way to set the property?
|
|
|
|
|
Hi,
Is it possoble to connect any database through c++?
How is it possible.
Thanks in Advance
|
|
|
|
|
No its not possible.
Well really, yes, there are lots of ways. The most popular two are ADO and ODBC.
Now where to begin.
http://www.codeproject.com/database/caaadoclass1.asp[^]
Carlos has put together some great wrappers around ADO which is a COM based method of connecting to databases.
If your new to database programming it may be worthwhile reaing up on what ADO and ODBC are on MSDN.
|
|
|
|