|
alfalf3 wrote: Have you experience the same problem?
No.
alfalf3 wrote: any idea on how to do so?
Yes: write a couple of functions, for instance:
BOOL SaveBmpTo12BitsFile(HBITMAP hBmp, HANDLE hFile);
HBITMAP LoadBmpFrom12BitsFile(HANDLE hFile);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You can use the below code to convert 2 unsigned shorts (4 bytes) into 3 bytes.
unsigned short s1 = 10;
unsigned short s2 = 20;
BYTE b1 = (s1 & 0x0FF0) >> 4;
BYTE b2 = (s1 & 0x000F) << 4;
b2 |= (s2 & 0x0F00) >> 8;
BYTE b3 = s2 & 0x00FF;
s1 = b1 << 4;
s1 |= (b2 & 0xF0) >> 4;
s2 = (b2 & 0x0F) << 8;
s2 |= b3;
«_Superman_»
|
|
|
|
|
Thank you _Superman_ (sounds weird )
I found a way (not the smartest I think) without bit shift:
typedef struct _PackedUShort
{
unsigned char b0 : 4;
unsigned char b1 : 4;
unsigned char b2 : 4;
unsigned char b3 : 4;
} PackedUShort;
typedef union
{
unsigned short us;
PackedUShort pack;
} PackedData;
packBuf = (PackedData*) myImageBuffer;
resultBuf = (PackedData*) malloc(sizeof(PackedData) * newSize);
for(i=0; i<imagesize;>{
int position = j % 4;
switch(position)
{
case 0:
(*resultBuf).pack.b0 = (*packBuf).pack.b0;
(*resultBuf).pack.b1 = (*packBuf).pack.b1;
(*resultBuf).pack.b2 = (*packBuf).pack.b2;
break;
case 1:
(*resultBuf).pack.b1 = (*packBuf).pack.b0;
(*resultBuf).pack.b2 = (*packBuf).pack.b1;
(*resultBuf).pack.b3 = (*packBuf).pack.b2;
resultBuf++;
break;
case 2:
(*resultBuf).pack.b2 = (*packBuf).pack.b0;
(*resultBuf).pack.b3 = (*packBuf).pack.b1;
resultBuf++;
(*resultBuf).pack.b0 = (*packBuf).pack.b2;
break;
case 3:
(*resultBuf).pack.b3 = (*packBuf).pack.b0;
resultBuf++;
(*resultBuf).pack.b0 = (*packBuf).pack.b1;
(*resultBuf).pack.b1 = (*packBuf).pack.b2;
break;
}
j+=3;
packBuf++;
}
}
----------------------
|
|
|
|
|
Hi Friends,
I have a dialog based MBCS application which creates the EDIT control over the dialog using CreateWindowExW API to support languages like Chinese, Japanese etc.
When I paste the Chinese characters into the EDIT control, it displays it correctly.
I call the GetWindowTextW to extract the content from the control into a wchar_t buffer.
But the debugger is not showing the value unless I call CharToOemW. What CharToOem does on that buffer? I would like to know more details with a functional comparison of APIs, WideCharToMultiByte and CharToOem.
Thank you
cheers
Varghese Paul
|
|
|
|
|
Please check whether you have enabled - "Display Unicode strings" option under Tools > Options > Debug tab.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
All multi-byte functions work on char buffers and not on wchar_t buffers.
«_Superman_»
|
|
|
|
|
Varghese Paul M wrote: But the debugger is not showing the value unless I call CharToOemW. What CharToOem does on that buffer?
I think that the CharToOEM function is converting the string buffer from UTF-8 into the default codepage on your operating system.
Code Page Identifiers[^]
Code Pages[^]
Code page[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Hi, I'm able to set the text and the background color of the text for Status bar, but I'm not able to set the color for the 'seperator' of the status bar.
I have 3 column on the status bar, each of the text and background I'm able to set it but have no luck on the 'seperator'
I've done it by creating a custom status bar inherited from CStatusBar
By drawing it on DrawItem
CODE:
CDC oDC;
CDC* pdc = CDC::FromHandle(pDIS->hDC);
pdc->FillSolidRect(&pDIS->rcItem, RGB(255,255,255));
oDC.Attach(pDIS->hDC);
oDC.SetTextColor(RGB(255,0,0));
oDC.SetBkColor(pDIS->itemData);
pDIS->rcItem.left += 2;
oDC.DrawText(_T("Test"),&pDIS->rcItem,DT_LEFT);
oDC.Detach();
Any ways to do this?
I wanted to change the whole status bar into white color RGB(255,255,255)
Any help would be appreciated.
KH
good
|
|
|
|
|
Is there any ways for me to set the seperator on the status bar become smaller?? by default, the width of it is 0.1cm
Or can I disable/remove the seperator between the item in the status bar ??
good
modified on Tuesday, January 13, 2009 3:03 AM
|
|
|
|
|
Did you try to handle the WM_CTLCOLOR to change the status bar color?
«_Superman_»
|
|
|
|
|
Do i Change the WM_CTLCOLOR on my CCustomStatusBar or on the MainFrm ?
KH
good
|
|
|
|
|
Hi all,
in VC++ by default the charcter set property for project is Use Unicode Character Set.
i want to knoe that which one is more efficient between Use Unicode Character Set and Use Multi-Byte Character Set for SDI type application.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
totally depends upon your requirement,if application need international character support, it need to be unicode aware.You don't have any choice.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
apology for my previous comment, both support International characted. But it totally depend on choice.
MBCS and Unicode[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
UNICODE.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: UNICODE.
good 5 point for
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Thanks.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I guess you didn't notice Iain's Post[^]...
Regards,
Sandip.
|
|
|
|
|
You guessed right, I missed it...Ooops, wait a minute, I never miss anything! I'm a god, after all!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
ThatsAlok upport CRY- Child Relief and You
Hi Alok,
So happy to see another CRY Supporter!
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Unicode would be more efficient because Windows internally uses Unicode.
«_Superman_»
|
|
|
|
|
What I'm using:
VC++ Version 6
MFC AppWizard (.exe)
What I have so far:
When I click a [Shuffle] button, the routine below creates the cards,
shuffles the deck, deals four cards and stores the position in deck
of the last card used .
============================
<pre>
void CAHADlg::OnShuffle()
{
int counter;
int pick;
// Creates Cards
CString card[53];
card[1] = "AS";
card[2] = "2S";
card[3] = "3S";
-----------------------
card[52] = "KH";
// Shuffles Cards
CString deck[53];
for(counter=0;counter<53;counter++)
{
deck[counter]="";
}
for(counter=1;counter<53;counter++)
{
pick=(rand()%52)+1;
while(deck[pick] != "")
{
pick=(rand()%52)+1;
}
deck[pick]=card[counter];
}
// Deals Cards and stores number of cards used
// deck[0] = position in deck of last card used
m_me1=deck[1];
m_dealer1=deck[2];
m_me2=deck[3];
m_dealer2=deck[4];
deck[0]="4";
UpdateData(FALSE);
}
</pre>
============================
What I want to do next:
Click on a [Draw A Card] button and have the routine:
Access the value of deck[0]
Convert the value of deck[0] to an integer and store the integer in variable int n.
Add 1 to n
Access the value of deck[n] and store it in m_me3
Convert the new n value to a string and store it in deck[0]
============================
What I don't know:
Object programming
How to access and change the value of an element of a foreign (same program, different routine) array
Would there me any difference between accessing or changing a foreign int array and accessing or changing a foreign string or char array?
|
|
|
|
|
Please, read the posting guidelines before posting (e.g. use the code tag to format your code properly).
dconnell wrote: How to access and change the value of an element of a foreign (same program, different routine) array
You can't because the array only exists in the scope of the function. Outside the function it doesn't exist.
However, what you could do is declare this array as a class member of the CAHADlg class. This way, it's lifetime is the same as your class, and you can access it from whatever function of the class.
|
|
|
|
|
I wrote some of the programs in Visual Studio and some of them in TASM and NASM. I've encrypted a program I want to hide using an ASM program that does a simple xor on the program. (I did this so no one may know how to write the code I've created, not for malware purposes, but so no one could steal or re-engineer my program.) Now I'm having issues executing the code which is now in memory. Will I need to use a higher level function like those in C++ or MASM to execute the code? I can't figure out how to access it. Many of my methods end in failure to execute. I'm sorry for the vagueness of my questions, but I figure I've been specific enough for help.
|
|
|
|
|
BobMMarley wrote: but I figure I've been specific enough for help.
Not really.
How are you loading the executable into memory? Are you using a PE loader stub which uses an XOR over the code section and then jumps into the original entry point?
Or have you used an XOR on some machine instructions and stored them into a string? If this is the case then the memory will be marked as non-executable and could fail. You can use the VirtualProtectEx Function[^] to modify the memory at that location and give it PAGE_EXECUTE_READWRITE permissions. Alternatively you cound use the VirtualAllocEx Function[^] to allocate some executable memory and copy the bytes into there.
Some documentation:
Data Execution Prevention[^]
DWORD dwLen = sizeof(YourShellCode);
LPVOID lpMemory = VirtualAllocEx(GetCurrentProcess(),0,dwLen,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
CopyMemory(lpMemory,YourShellCode,dwLen);
Best Wishes,
-David Delaune
|
|
|
|