|
CString CAutoMsnDlg::Decode_8_to_7(CString &str_Input_8_bits)
{
unsigned short temp [1000] ;
unsigned short result [1000];
int length = str_Input_8_bits.GetLength();
for ( int i = 0 ; i < length; i ++ )
{
if ( ( str_Input_8_bits [i] >= '0') && ( str_Input_8_bits [i] <= '9' ) )
temp [i] = str_Input_8_bits [i] - '0' ;
else
if ( str_Input_8_bits [i] >= 'A' )
temp [i] = str_Input_8_bits [i] - 'A' + 10 ;
else
temp [i] = str_Input_8_bits [i] - 'a' + 10 ;
}
for ( i = 0 ; i < length ; i+=2 )
{
temp[i/2] = (temp[i]<<4 ) | temp[i+1];
}
length = length / 2 ;
for ( i = 0 ; i < length/7 ; i++ )
{
result [i*8 + 0] = ( temp [i*7 + 0] & 0x7f ) ;
result [i*8 + 1] = ( ( temp [i*7 + 1] & 0x3f ) << 1 ) | ( temp [i*7 + 0] >> 7 ) ;
result [i*8 + 2] = ( ( temp [i*7 + 2] & 0x1f ) << 2 ) | ( temp [i*7 + 1] >> 6 ) ;
result [i*8 + 3] = ( ( temp [i*7 + 3] & 0x0f ) << 3 ) | ( temp [i*7 + 2] >> 5 ) ;
result [i*8 + 4] = ( ( temp [i*7 + 4] & 0x07 ) << 4 ) | ( temp [i*7 + 3] >> 4 ) ;
result [i*8 + 5] = ( ( temp [i*7 + 5] & 0x03 ) << 5 ) | ( temp [i*7 + 4] >> 3 ) ;
result [i*8 + 6] = ( ( temp [i*7 + 6] & 0x01 ) << 6 ) | ( temp [i*7 + 5] >> 2 ) ;
result [i*8 + 7] = ( temp[i*7 + 6] >> 1 ) ;
}
i = length/7 ;
if ( i*7 + 0 < length )
result [i*8 + 0] = temp [i*7 + 0] & 0x7f ;
if ( i*7 + 1 < length )
result [i*8 + 1] = ( ( temp[i*7 + 1] & 0x3f ) << 1 ) | (temp[i*7 + 0] >> 7 );
if ( i*7 + 2 < length )
result [i*8 + 2] = ( ( temp[i*7 + 2] & 0x1f ) << 2 ) | (temp[i*7 + 1] >> 6 );
if ( i*7 + 3 < length )
result [i*8 + 3] = ( ( temp[i*7 + 3] & 0x0f ) << 3 ) | (temp[i*7 + 2] >> 5 );
if ( i*7 + 4 < length )
result [i*8 + 4] = ( ( temp[i*7 + 4] & 0x07 ) << 4 ) | (temp[i*7 + 3] >> 4 );
if ( i*7 + 5 < length )
result [i*8 + 5] = ( ( temp[i*7 + 5] & 0x03 ) << 5 ) | (temp[i*7 + 4] >> 3 );
if ( i*7 + 6 < length )
result [i*8 + 6] = ( ( temp[i*7 + 6] & 0x01 ) << 6 ) | (temp[i*7 + 5] >> 2 );
int new_length = length*8/7 ;
CString str_Output_7_bits = CString ( result , new_length);
return str_Output_7_bits;
}
CString CAutoMsnDlg::Decode_7_to_8(CString &str_Input_7_bits)
{
unsigned short temp [1000];
unsigned short result [1000];
int i=0;
int length = str_Input_7_bits.GetLength();
for ( i = 0 ; i< length/8 ; i++ )
{
temp [i*7 + 0] = ( ( str_Input_7_bits[i*8 + 0] >> 0 ) & 0x7f ) | ( str_Input_7_bits[i*8 + 1] << 7 ) ;
temp [i*7 + 1] = ( ( str_Input_7_bits[i*8 + 1] >> 1 ) & 0x3f ) | ( str_Input_7_bits[i*8 + 2] << 6 ) ;
temp [i*7 + 2] = ( ( str_Input_7_bits[i*8 + 2] >> 2 ) & 0x1f ) | ( str_Input_7_bits[i*8 + 3] << 5 ) ;
temp [i*7 + 3] = ( ( str_Input_7_bits[i*8 + 3] >> 3 ) & 0x0f ) | ( str_Input_7_bits[i*8 + 4] << 4 ) ;
temp [i*7 + 4] = ( ( str_Input_7_bits[i*8 + 4] >> 4 ) & 0x07 ) | ( str_Input_7_bits[i*8 + 5] << 3 ) ;
temp [i*7 + 5] = ( ( str_Input_7_bits[i*8 + 5] >> 5 ) & 0x03 ) | ( str_Input_7_bits[i*8 + 6] << 2 ) ;
temp [i*7 + 6] = ( ( str_Input_7_bits[i*8 + 6] >> 6 ) & 0x01 ) | ( str_Input_7_bits[i*8 + 7] << 1 ) ;
}
i = length/8 ;
if ( i*8 + 0 < length -1 )
temp [i*7 + 0] = ( ( str_Input_7_bits [i*8 + 0] >> 0 ) & 0x7f ) | ( str_Input_7_bits [i*8 + 1] << 7 ) ;
if ( i*8 + 1 < length -1 )
temp [i*7 + 1] = ( ( str_Input_7_bits [i*8 + 1] >> 1 ) & 0x3f ) | ( str_Input_7_bits [i*8 + 2] << 6 ) ;
if ( i*8 + 2 < length -1 )
temp [i*7 + 2] = ( ( str_Input_7_bits [i*8 + 2] >> 2 ) & 0x1f ) | ( str_Input_7_bits [i*8 + 3] << 5 ) ;
if ( i*8 + 3 < length - 1)
temp [i*7 + 3] = ( ( str_Input_7_bits [i*8 + 3] >> 3 ) & 0x0f ) | ( str_Input_7_bits [i*8 + 4] << 4 ) ;
if ( i*8 + 4 < length - 1)
temp [i*7 + 4] = ( ( str_Input_7_bits [i*8 + 4] >> 4 ) & 0x07 ) | ( str_Input_7_bits [i*8 + 5] << 3 ) ;
if ( i*8 + 5 < length -1 )
temp [i*7 + 5] = ( ( str_Input_7_bits [i*8 + 5] >> 5 ) & 0x03 ) | ( str_Input_7_bits [i*8 + 6] << 2 ) ;
if ( i*8 + 6 < length - 1)
temp [i*7 + 6] = ( ( str_Input_7_bits [i*8 + 6] >> 6 ) & 0x01 ) | ( str_Input_7_bits [i*8 + 7] << 1 ) ;
if ( (i*8 + 0) == length-1)
temp [i*7 + 0] = ( ( str_Input_7_bits [i*8 + 0] >> 0 ) & 0x7f );
if ( (i*8 + 1) == length-1)
temp [i*7 + 1] = ( ( str_Input_7_bits [i*8 + 1] >> 1 ) & 0x3f ) ;
if ( (i*8 + 2) == length-1)
temp [i*7 + 2] = ( ( str_Input_7_bits [i*8 + 2] >> 2 ) & 0x1f ) ;
if ( (i*8 + 3) == length-1)
temp [i*7 + 3] = ( ( str_Input_7_bits [i*8 + 3] >> 3 ) & 0x0f ) ;
if ( (i*8 + 4) == length-1)
temp [i*7 + 4] = ( ( str_Input_7_bits [i*8 + 4] >> 4 ) & 0x07 ) ;
if ( (i*8 + 5) == length-1)
temp [i*7 + 5] = ( ( str_Input_7_bits [i*8 + 5] >> 5 ) & 0x03 ) ;
if ( (i*8 + 6) == length-1 )
temp [i*7 + 6] = ( ( str_Input_7_bits [i*8 + 6] >> 6 ) & 0x01 ) ;
int iNewLength = length*7/8 + ((length%8) ? 1 ) ;
iNewLength = 2 * iNewLength ;
for ( i = 0 ; i <iNewLength ; i=i+2 )
{
result [i] = ( temp [i/2] >> 4 ) & 0x0f ;
result [i+1] = ( temp [i/2] >> 0 ) & 0x0f ;
}
for ( i = 0 ; i < iNewLength ; i ++ )
{
if ( result [i] >= 0 && result [i] <=9 )
{
result [i] = result [i] + '0' ;
}
else
{
result [i] = result [i] - 10 + 'A';
}
}
CString str_Output_8_bits = CString ( result, iNewLength );
return str_Output_8_bits;
}
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Papa,
Thank you very much for the time and effort you've put into this. I really appreciate it. Unfortunately I get a compile error with your code on the following lines:
in Decode_8_to_7 before returning:
CString str_Output_7_bits = CString (result , new_length);
and in Decode_7_to_8, before returning:
CString str_Output_8_bits = CString ( result, iNewLength );
the error is the same in both cases:
error C2665: 'ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > >::__ctor' : none of the 18 overloads can convert parameter 1 from type 'unsigned short [1000]'
I'm not great with types and type casting. Can anyone please help?
Thanks once again,
Steph
|
|
|
|
|
What is the code for opening an OPen File Dialog Box? I found something with GetOpenFileName, but...
Thanks!
|
|
|
|
|
Hi,
Try
TCHAR szFilters[] = _T("txt - files(*.txt)|*.txt|");
CFileDialog MyDialog (FALSE, _T("txt"), _T("*.txt"), OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT, szFilters);
if (MyDialog.DoModal() == IDOK)
'FALSE' file save dialog
'TRUE' file open dialog
|
|
|
|
|
x-trate wrote:
I found something with GetOpenFileName, but...
Thanks!
But what? GetOpenFileName() is the right function. If you are using MFC, check out the CFileDialog class.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
OPENFILENAME ofn;
char szFileName[1024]; szFileName[0]='\0';
ZeroMemory(&ofn,sizeof(ofn));
ofn.lStructSize=sizeof(OPENFILENAME);
ofn.Flags=OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;
ofn.lpstrFilter="Media Files (*.mp3)\0*.mp3\0,(*.wma)\0*.wma\0,(*.avi)\0*.avi";
ofn.lpstrDefExt="bmp";
ofn.lpstrFile=szFileName;
ofn.nMaxFile=512;
GetOpenFileName(&ofn);
gabby
|
|
|
|
|
Hi,
I am running an .avi file in MCI window. I want to show multiple frames together.
For example if a person is playing golf I want to show whole trajectory as he move his stick to hit ball.
Is there any way that I can show multiple frames together
in one window.
I will appreciate any suggestion.
Thanks for your time....
|
|
|
|
|
Are there good security code for Win32 system objects ?
I need to set password for some local folder,
for some user.
Usually it is supposed to use ACE, DACL, SACL, so on -
too many complex conversation in relation to task.
Can it be that some people wrote code/library
that simplify/encapsulates this task in more
object based/easy to use way ?
Please supply link.
also, Please point me how to do desired method more easily,
in a some more organized way.
thanks you.
|
|
|
|
|
Good day to all!I have a problem that gives crack to my skull. Im compiling my program in release mode when i encountered this problem "fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'E:\8168\vc98\p2\src\P2\main.c', line 494)". i check the microsoft website about this problem and then giving this solution:
Please use one of the following workarounds:
1.)Compile with /Zi instead of /ZI.
2.)Supply a file name with /Yc; i.e. /Yc"filename".
which i dont know where to locate this solution... can anyone explain to me where to fix these bugs. i already have the service pack 6 of visual studio...
|
|
|
|
|
You can add those compiler switches to either the project's .dsp file directly, or the IDE.
That said, I question how either workaround is supposed to address the C1001 error. Was there another error that preceeded the C1001 error? What does line 494 (and maybe several before it) of main.c look like?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
How do change a dialog box font, size in runtime. can u please help for the same in win32 api. If an example is good for us.
Thanks in Advance
|
|
|
|
|
With MFC:
m_someEditbox.SetFont( &m_font );
where m_font is a CFont member of your dialog class.
API-version:
SendMessage( handletocontrol, WM_SETFONT, (WPARAM)fonthandle, MAKELPARAM(redraw, 0);
where handletocontrol is a handle to the control to set the font for, fonthandle is the handle to a font (!) and redraw is a BOOL flag, either TRUE or FALSE if the control should be redrawn immediately.
|
|
|
|
|
HI!
When I'm debugging and stepping through my code, in certain places I get the message "There is no source code available for the current location.", even though it is my own code, and the files are in my project... Anyone know how to fix this?
Øivind
|
|
|
|
|
Check it:
Tools->Options->Projects->VC++Derictories->Source File
|
|
|
|
|
still doesn't work... any other ideas?
ØIvIND
|
|
|
|
|
Is it possible to make my popup CDilalog into another Cdialog (making it as a child) I’ve figured of the CWnd::ModifyStyle func but it return false when I for e.g. run:
m_dialog.ModifyStyle(ModifyStyle( 0 ,WS_CHILD );
Any suggestions how I could tackle the problem.
I’ve searched for articles round the net but no success…
Thanks
_____________________________
...and justice for all
APe
|
|
|
|
|
d00_ape wrote:
m_dialog.ModifyStyle(ModifyStyle( 0 ,WS_CHILD );
Of course:
m_dialog.ModifyStyle( 0 ,WS_CHILD );
_____________________________
...and justice for all
APe
|
|
|
|
|
helloo all fellow programmer
i want to know loginc behind or any api behind copying one directory from one drives to other.
thanks in advance
I Think It will Work
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Have you looked at SHFileOperation() ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
HI!
When I'm debugging and stepping through my code, in certain places I get the message "There is no source code available for the current location.", even though it is my own code, and the files are in my project... Anyone know how to fix this?
|
|
|
|
|
Hi how i can detect modem (name of one)which installed in my system,programatically?????
Thank.
|
|
|
|
|
http://www.codeguru.com/Cpp/I-N/network/dial-upnetworking/article.php/c2465/
|
|
|
|
|
Hi!
I've have overridden CWnd::OnNcLButtonUp() to detect when I click on the title bar of my window. What I need now is to detect if I have released the window. This is so I click on my title bar and drag window to another position. How do I know when the drag has finished?
I have tried CWnd::OnNcLButtonUp() but it doesn't help.
|
|
|
|
|
|
Doesn't this just state the obvious. If you are writing native code then C++ will be faster!?! Given the speed of modern machines the majority of applications speed is not noticably different, from a user point of view, no matter what language they are written in.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|