|
I think there was a typo in the other post.
Anyway, mod it with 2 and you'll either get back 1 or 0. For instance:
1 % 2 = 1
2 % 2 = 0
3 % 2 = 1
... and so on. E.g.,
bool IsEven(int j)
{
if(j % 2 == 1)
return false;
else
return true;
}
This could certainly be optimised if high performance is needed... I just posted a simple version.
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
Hi, I am trying to make an installer for my app. Id like to have all data(files) in one exe file. How should I append or insert these files to my installer application and how to aproach them?
Thanks.
|
|
|
|
|
Instead why dont you import the files as custom resource into your installer, then at installation use the resource handling functions to load and write it to the harddisk.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Thx, but what are these resource handing function?
|
|
|
|
|
To start with...
LoadResource(...);
LockResource(...);
SieofResource(...);
I dont have a sample, try looking for these apis may be you will get one.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
You can do it, as the other poster said, by shoving your files into resources in your EXE.
You might be better off getting a commercial package that creates self-extracting ZIP files (I think WinZip can do this but I'm not sure. I know there are others.)
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
I have 32 bit uncompressed bitmap stored in my application's resources.
I need to load this 32bit bitmap's data for some processing, before it
will be displayed to user.
I'm using GetBitmapBits().
This is working perfectly, but only when my screen is set to display 32 bit colors.
When I switch system's display mode to 16 - bit, this function is not working as expected - it's giving me 16 bit bitmap data.
How to get bitmap's data always in 32 bit ?
Maybe GetDIBits() could do this, but I don't know which DC to use as
first parameter.
Any ideas please ?
Thanks !
rrrado
|
|
|
|
|
Hmm..
Bitmaps are usually selected into a device context, and generally, you create a device context that represents the current display. The best way to alter this behaviour is to manually create a DC large enough to hold your bitmap, and with the correct color depth. Then, you can select this bitmap into a device context and use the device context's functions to retrieve the color of each pixel. The problem with GetBitmapBits is that it creates a screen-compatible DC to which the bitmap is selected, and bases it's results into the return values of pixel query on the DC surface. Thus, if the DC is set to 16-bit depth, the resulting bit array consists of 16-bit data.
I'm not sure, but the DC parameter of GetDIBits represents a device context into which the device dependant bitmap is to be selected. The best way to proceed would be to create arbitary device contextes with different color depths, and see how the resulting bitmap bits vary.
The easiest way, of course, is to force the display to 32-bit depth before doing the loading: just put a 32-bit screen depth as a prerequisite for your application.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks for answer,
but application must run also on 256 color displays,
The problem is that I don't know how to create 32 bit DC manually,
without 32 bit display colors. Maybe it's not possible.
In worst case I'll have to store bitmap data as raw data in resources
rrrado
|
|
|
|
|
Hi,
does anyone know of debuggers available which were programmed using MFC's. It would be of some use as I need to know how to display a disassembly file
Kind regards
Caoimh
|
|
|
|
|
|
let me put the question diferently.
I've an assembly file and I want to display the disassembly file of this to a mfc application. How would this be done??
|
|
|
|
|
Get the manual for instruction set fromthe www.intel.com site for the processor and decode the opcode the way you want to.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Is there a function or code to lock my computer,like this: you need a password to enter in application to enable using computer.The program should lok all functions of computer,and it should be turned off only by password!
Thanx
|
|
|
|
|
LockWorkStation();
Don't try it, just do it!
|
|
|
|
|
Just use a password-enabled screen saver. To enable it programmatically, check out the following value in the registry:
HKEY_CURRENT_USER\Control Panel\Desktop\ScreenSaverIsSecure
The alternative, LockWorkStation() , only works on Windows 2000 and newer machines.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi all,
I have client application and server application (FTP server / client). On client side, due to certain reasons, I use CArchive to write / read data to / from socket. On the server side I use CSockets to send / receive data.
It worked fine for me, but now I implemented encrypted communication (Twofish cipher) and want to exchange the data safely. When I send encrypted data from client to server (ie. CArchive::Write()), it is ok. But when I use CSocket::Send() to send encrypted data from server to client, on client side the call of CArchive::Read() doesn't return and after a while it throws CFileException (OS Error it says).
My method for sending encrypted data from server to client is the following:
[CODE]
DWORD dwToAllocate = CTwofishCipher::getPaddedSize(strlen(s) + 3) + TC_BLOCK_HEADER_SIZE;
BYTE* encryptedData = new BYTE[dwToAllocate];
memset(encryptedData, 0x00, dwToAllocate);
encryptAnswer(stringToSend, encryptedData);
pControlSocket->sendEncryptedString(encryptedData, dwToAllocate);
void CMyControlSocket::sendEncryptedString(BYTE* encryptedData, INT dataLen)
{
CSocket::Send(encryptedData, dataLen, 0);
}
[/CODE]
And the code of client for receive encrypted data is here:
[CODE]
BYTE* receivedData = NULL;
UINT nBytesRead = 0;
TRY
{
receivedData = (BYTE *) m_retmsg.GetBuffer(32000);
nBytesRead = m_pCtrlRxarch->Read((TCHAR*) receivedData, 32000);
m_retmsg.ReleaseBuffer();
}
CATCH(CFileException ,e)
{
ErrorCode = e->m_lOsError;
return FALSE;
}
END_CATCH
[/CODE]
The interesting is that when I check received data on client side (after it throws the exception after a while), the bytes received exactly match the bytes which had been sent. Anyway, the function CArchive::Read() has apparently some difficulty receiving the buffer.
Thanks for any suggestion!
|
|
|
|
|
hi,
for a project fot school in need a struct array whith a length of 22510....If i debug the program it seems the array has only a length of 1024...
Does some know if there is a maximum lenght of arrays in borland c++ builder and how i can solve this problem??
Ben Tros
Ben_Tros@hotmail.com
|
|
|
|
|
ben_tros wrote:
how i can solve this problem??
Allocate your array dynamically (also don't forget to free it when you don't need it anymore)
Ashes to ashes,
And clay to clay
If the enemy doesn’t get you,
Your own folk may
|
|
|
|
|
Is this a heap array or a stack array? For example:
int num[250000];
would create an array of 250,000 integers, and consume 1MB of the available stack. The default stack size for a VC++ program is 1MB, so this would most likely fail as there would be no room for anything else in the program.
This statement, however, would execute with no problems as it allocates from the heap:
int *num = new int[250000];
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
The max Len of an array generally is assumed to be Maximum Unsigned Integer or possibly 2^64(depending on system). I don't know any more. Generally a dynamicly maitained array doesn't need to worry about maximum size any more. It just needs to have good memory managment behind it.
|
|
|
|
|
There isn't a maximum in C++. However, various debug views may set a maximum for performance reasons... in other words, it may take forever for a debugger to show all 22510 nodes of an array, so it may be limiting it to 1024. This shouldn't affect your code at all though.
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
How to Create a Button with Tooltip in "win32 application project"?
|
|
|
|
|
|
Hi,
is it possible to have a combo box display both text and an icon without resulting to owner drawing it? (im not using MFC)
Any example would be ace and also if i do have to draw it, any examples would be great!
Cheers
Skute
|
|
|
|