|
Create a memory DC
Select the bitmap into it (saving the previously selected bitmap)
Render your text on the DC
Select the saved bitmap back into the DC (this un-selects your bitmap from the DC)
Destroy the DC
The only catch here is, if the HBITMAP is not a DIBSection, then the DC will need to be
compatible with the bitmap or selecting the bitmap into the DC can fail.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes its possible you need to a handle to DC(Createompatibledc) and for other steps see Mark's answer.
|
|
|
|
|
Hi all,
I am trying to convert a long file path ( more than 255 chars, in UNC format) using GetShortPathNameW API. But It fails, saying that
"The filename, directory name, or volume label syntax is incorrect."
Anybody knows what is issue here?
|
|
|
|
|
Probably the filename or the directory name or the volume label syntax is incorrect, I suppose.
BTW have you read the following note (from MSDN [^]):
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
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
|
|
|
|
|
I have used GetShortPathNameW (unicode version ) only
sample path is as follows:
"\\?\UNC\server_ip\ONTAP_ADMIN$\vol\vol0\home\testdir4\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"
modified on Wednesday, April 23, 2008 10:25 AM
|
|
|
|
|
Well, I get error 3 (the system cannot find the path specified), that is quite different. How do you call the function?
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
|
|
|
|
|
Here is the sample code
<br />
DWORD dw =0;<br />
wstring m_UNCPath = L"Long file name";
<br />
long length = GetShortPathNameW(m_UNCPath.c_str(), NULL, 0);<br />
DWORD dwerror = GetLastError();<br />
<br />
<br />
length += 2;<br />
wchar_t* buffer = new wchar_t[length];<br />
<br />
dwerror= GetShortPathNameW(m_UNCPath.c_str(), buffer, length); <br />
|
|
|
|
|
Some updates here are
If the path is given like
"\\?\c:\..."
things works
but for path
"\\?\UNC\c:\..."
things fails.
Most important I want to get shortpath name over network
so my path becomes
"\\?\UNC\ip_address\..."
Here things fails badly.
|
|
|
|
|
My test:
void main()
{
WCHAR szShort[MAX_PATH];
DWORD dw =0;
wstring m_UNCPath = L"C:\\Documents and Settings\\01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234.txt";
long length = GetShortPathNameW(m_UNCPath.c_str(), szShort, MAX_PATH);
}
resulting value of szShort :
"C:\DOCUME~1\012345~1.TXT"
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
|
|
|
|
|
Please recheck your path. I guess it's less then 255 chars.
|
|
|
|
|
Damn, you're right, Windows truncated the name...
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
|
|
|
|
|
See you can not create a long file path simply in windows explorer.It is not supported. You need to call apis like CreateDirectoryEx and CreateFileW to create such path and write a file inside it.
|
|
|
|
|
Hi! I have some transport which based on winsock. Client(FTPS) send to me some data over SSL, and i receive it with (for example):
<br />
...<br />
if (WSARecv(AcceptSocket, &DataBuf, 1, &RecvBytes, &Flags, &AcceptOverlapped, NULL) == SOCKET_ERROR){<br />
if (WSAGetLastError() != WSA_IO_PENDING)<br />
printf("Error occured at WSARecv()\n");<br />
}<br />
...<br />
how can i decrypt received data in DataBuf, if i have certificate, puclic and private keys?
|
|
|
|
|
|
helo,
I want to write socket client application by using c or c++ in window without using any Winsock or MFC class.
how do i achieve it.
I search it but not getting exactly .
Regards,
Amit
|
|
|
|
|
Are you kidding?
AFAIK even Cygwin uses Winsock library.
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
|
|
|
|
|
There are many network libraries out there. For instance, take a look at Boost Asio[^]
|
|
|
|
|
Don't you have to write your own communication interface between the TCP/IP stack and your software ? or something like that ?
|
|
|
|
|
|
See here[^] does helpful?
|
|
|
|
|
Does it seem reasonable to load a 40-sec WAV to a 'static' DirectSound secondary buffer to play as my game background-music ?
If not, why not ?
The other option, AFAIK, is having 'streaming' buffer for that. Which will be more complicated programmatically.
|
|
|
|
|
Hanan888 wrote: Does it seem reasonable to load a 40-sec WAV to a 'static' DirectSound secondary buffer
Yes.
Maximum buffer size is 0x0FFFFFFF...40 seconds 0f 44.1kHz, 24-bit stereo
audio samples is around 10MB (if I did the math correctly ).
Should work fine.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks.
So, my kitschy background music won't break the system after all... perhaps the people listening to it would...
Mark Salsbery wrote: Maximum buffer size is 0x0FFFFFFF...40 seconds 0f 44.1kHz, 24-bit stereo
audio samples is around 10MB (if I did the math correctly ).
Have you calculated something like this -
buffer size:
0X0FFFFFFF = 16^7 - 1 bytes = 268,435,455 bytes
WAV size:
40 sec * 3 bytes per sample (24-bit) * 44100 samples per second = 5,292,000 bytes
|
|
|
|
|
Hanan888 wrote: Have you calculated something like this -
buffer size:
0X0FFFFFFF = 16^7 - 1 bytes = 268,435,455 bytes
WAV size:
40 sec * 3 bytes per sample (24-bit) * 44100 samples per second = 5,292,000 bytes
Yes, except I took a worse-case scenario (unless you use a higher sampling rate ) and chose
stereo, so I multiplied your WAV size by 2.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm developing an animated-game on Win32.
It runs only in windowed mode.
I'm creating my window with the styles WS_OVERLAPPED | WS_SYSMENU so that it has a blue frame, with a blue title on top, much like the window you have right now if you're a Windows user.
We decided we want to support users with 800X600 screen (is there any of those left?), by means we want the window to fit into a 800X600 screen. If I create the window in size 800X600, it won't fit, since the frame is not included in the 800X600 I specified, it will be like 810X625 or something like that.
The question is how do I know the exact size in pixels of the frame ? or what might be considered the maximal size so I could just do for example 740X550 window and it will always fit ?
|
|
|
|