|
Hello!
I searched all over the net for the following solution. I have some MFC dialog based application. I still want to use printf, cout, etc., but there is no console window, just dialog. Is there some way to use stdout the same way like in command prompt programs?
I found one way of doing this:
AllocConsole();
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),(void *)out,(DWORD)strlen(out),&written,0);
but the problem here is that you have to use WriteFile function and cout or printf does not work.
Best regards,
Rostfrei
|
|
|
|
|
You can show a console, by adding the following line in Post-Build in Project Properties (VC2003) or Project Settings Post-Build Step (VC6).
editbin /SUBSYSTEM:CONSOLE "$(OUTDIR)"\<program name="">
Where program name is the name of your final build exe.
If i am building Notepad.exe, then it would be
editbin /SUBSYSTEM:CONSOLE "$(OUTDIR)"\notepad.exe
You can also call it from cmd.exe manually
editbin /SUBSYSTEM:CONSOLE c:\programfiles\etc\etc\notepad.exe
Usman
|
|
|
|
|
Thank you very much. That is exactly what I needed.
Best regards,
Rostfrei
|
|
|
|
|
Friends,
We can detect that IE is currently set to 'Work Offline' using InternetGetConnectedState() .
If detected, i want to programatically change the 'Work Offline' state to the normal 'Online' state. How can i do so ?
Imtiaz
|
|
|
|
|
Imtiaz Murtaza wrote:
If detected, i want to programatically change the 'Work Offline' state to the normal 'Online' state
check is this api [InternetGoOnline ] help
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
ThatsAlok wrote:
check is this api [InternetGoOnline] help
It is forcing me to open some page.
Imtiaz
|
|
|
|
|
What is your Mode of your Internet connection! i.e. Is it through CABLE or DIALUP.
If DialUp you can use these api's too [InternetAutodial] and [Internetdial]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I switched my browser to offline mode and opened Outlook Express Mail client. It immediately popped up a dialog that IE is in offline mode and whether I want to switch it to online mode. If I press "yes" it automatically changes it to online mode. As such there must be some way that external applications can switch the browser to online mode, afterall Outlook Express does this.
Imtiaz
|
|
|
|
|
I would look into InternetCheckConnection(...) , it has a flag that forces connection; and InternetAttemptConnect(...) .
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi all,
I do a job relating to SOAP initialize. Sometime, SOAP initialize fail
because, SOAP uses Wininet library as default and uses the proxy setting in IE, and this setting was not correct . Some one recommended me to use Winhttp instead of Wininet.
Dim Client
Set Client = Server.CreateObject ("MSSoap.SoapClient30")
Client.ClientProperty("ServerHTTPRequest") = True
Call Client.mssoapinit("http://..../SampleWSDL.wsdl",
"http://...../SampleWSML.wsml")
If Client.ClientProperty("ServerHTTPRequest") = True, SOAP will use Winhttp instead of Wininet.
But I don't know what differences between Winhttp and Wininet are?
Any of u have experiences about this? Can u help me to answer following questions:
1. What are differences between WinInet and WinHTTP? (using in SOAP)
2. problems if we use WinHTTP.
Client.ClientProperty("ServerHTTPRequest") = True
Thanks very much for any your ideas,
Tin Le
|
|
|
|
|
How to get the PhysicalDrive number which the logical drive located?
Like how to get the PhysicalDrive number of "C:" logical drive ?
Thanks a lot!
Let's roll!
|
|
|
|
|
HI Dragon,
have a look at Win32_DiskDrive WMI Class!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
LPTSTR lpVolumeNameBuffer[100];
LPDWORD lpVolumeSerialNumber;
LPDWORD lpMaximumComponentLength;
LPDWORD lpFileSystemFlags;
LPTSTR lpFileSystemNameBuffer[100];
GetVolumeInformation("C:\\",lpVolumeNameBuffer,100,&lpVolumeSerialNumber,
lpMaximumComponentLength,lpFileSystemFlags,lpFileSystemNameBuffer,100 );
use the above function it returns the Volume Serial Number of the physical C drive .
Cheers ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Hmmm. How about:
<br />
TCHAR caVolumeNameBuffer[ 100 ];<br />
DWORD dwVolumeSerialNumber = 0;<br />
DWORD dwMaximumComponentLength = 0;<br />
DWORD dwFileSystemFlags = 0;<br />
TCHAR caFileSystemNameBuffer[ 100 ];<br />
<br />
GetVolumeInformation( _T( "C:\\" ), caVolumeNameBuffer, 100, &dwVolumeSerialNumber, &dwMaximumComponentLength, &dwFileSystemFlags, caFileSystemNameBuffer, 100 );<br />
Your example was not passing in valid pointers, only uninitialized ones. Might want to ensure proper termination of the TCHAR buffers as well.
However, I think the OP was asking about the physical device name for the drive, not its serial number; I think they were looking for information such as if a drive is \\.\PhysicalDrive0 or \\.\PhysicalDrive1 , etc. You need that information to open the device itself (the hard drive itself) to do things like send IOCTLs. I do not think that the function you specified will return that information.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
If you need that to do something like send IOCTLs (DeviceIoControl ), you can also open the device by using the following syntax:
\\.\C: - Open physical device for drive "C"
\\.\D: - Open physical device for drive "D"
\\.\A: - Open physical device for drive "A"
I do not know all of the cases where that format and the \\.\PhysicalDrivex format are interchangable, but I know you can use it when getting a HANDLE to use with DeviceIoControl .
Also, not that you are likely to hit it, but there is a bug in older versions of the Win32_DiskDrive WMI class that limits the number of drives returned. The above method should also work on Windows NT 4.0 versions prior to SP4, but the WMI method will not.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Thanks a lot! I just need to use \\.\PhysicalDrivex to open the disk contains the appointed logical volumn.
I've lookup in MSDN and found the method.
Use DeviceIoControl and send IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS.
But MSDN says it can only use in win2000 and later version.
Let's roll!
|
|
|
|
|
Hi!
In my application I get a top down raw bitmap that can be of 1,8,24 bits per pixel.
I get this in the form of Bitmapfileheader, BitmapInfo and then bitmap data in a buffer.
Now I want to add a watermark to this image without changing any of its properties like bits per pixel , width , height etc...and get the bitmapdata buffer modified.
Basicaly I am getting this image in some way, I have to just add watermark and send it to printer...
Can anybody tell me what is the easiest way to do this ..with minimum amount of memory involved...Preferably using only win32 APIs...
Thanks
|
|
|
|
|
If you want to add a watermark, that's a blend of your info and the info there, so you probably want to manipulate the bitmap data directly. There's no extra memory required, because you're using the array you have, not creating any others.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi!
Can you give me some sample code or some link where I can find such sample
It will be of great help...
Thanks
|
|
|
|
|
You can read my image processing articles for general help, and there is an article on watermarking here on CP as well.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for ur help... But I have a very basic problem, I get the info about bitmap as a parameter, what I get is 3 parameters BITMAPINFO, BITMAPFILEINFO, and BitmapData in a buffer.
Now my problem is how to get HBITMAP from this?
I tried CreateBitmap() but as my bitmap has got negative height it fails.
I treid with CreateDIBitmap() but it creates a bitmap with 32bit/pix where as my original bitmap was only 1 bit/pix. and also makes height positive.
Now my second question is if I have created a bitmap and recvd. HBITMAP then I will write text on that. What I want is that my buffer which is holding BitmapData is modified and I get that buffer so that I can pass that to another function.
So what actually i am interested in is how to get modified buffer which is holding bitmapdata.
Thanks
|
|
|
|
|
Naveen_mah wrote:
I tried CreateBitmap() but as my bitmap has got negative height it fails.
It probably has a negative height because the scanlines in a bitmap go from the bottom to the top. try reversing the sign, perhaps ?
Given that you have the bitmapdata, you can create a DIBSection ( which has a HBITMAP and a pointer to bitmap data ) and copy your data into it. A DIBSection is very likely to solve a lot of your problems, actually.
Naveen_mah wrote:
Now my second question is if I have created a bitmap and recvd. HBITMAP then I will write text on that.
If your HBITMAP is a DIBSECTION, then GetObject will return a BITMAP structure with a pointer to the bits. If this fails, you need to create a DIBSECTION and copy your HBITMAP into it, BitBlt will do this for you.
Naveen_mah wrote:
What I want is that my buffer which is holding BitmapData is modified and I get that buffer so that I can pass that to another function.
Yes, if you have a buffer with bitmap data, modifying that seems the best approach, which is what I suggested in the first place.
Naveen_mah wrote:
So what actually i am interested in is how to get modified buffer which is holding bitmapdata.
You have bitmap data, I'm suggesting you iterate through it and modify it, not that you turn it into a HBITMAP or use any GDI functions on it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
You have bitmap data, I'm suggesting you iterate through it and modify it, not that you turn it into a HBITMAP or use any GDI functions on it.
How can I do that? What I have to write is a text that can be on any size, angle, color, font, and more over I want it to be transparent so that text and bitmap both are seen.
So how can I modify the bitmap data directly without using GDI API's
Thanks
|
|
|
|
|
Naveen_mah wrote:
How can I do that? What I have to write is a text that can be on any size, angle, color, font, and more over I want it to be transparent so that text and bitmap both are seen.
The fact that you want to merge text with the bitmap underneath DEMANDS that you do it directly, unless you use GDI+, in which case you can create a semi transparent brush to draw the text for you.
Naveen_mah wrote:
So how can I modify the bitmap data directly without using GDI API's
Well, you have the bitmap data as a byte array, so you would figure out where you want to put something, and iterate through the bits, placing it on. I didn't realise you wanted to rotate your text, or change it's colour, I assumed you had a standard watermark you wanted to add, in which case you could store it in a resource bitmap, and use the values in that bitmap to merge into your source image.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
![Go to Parent](https://www.codeproject.com/App_Themes/CodeProject/Img/arrow-up24.png) So what do u think is the best way to do this? As my watermark is dynamic and can be of any kind.
Below is the code I have simplified and pasted here, But I am not able to BitBlt bitmap and getting insuficient memory error...
Can anybody help me out ...where I have gone wrong?
My bitmap is 1 bit bitmap and is top down bitmap 2275x3300 (file size 928 KB)
<br />
void AddText(HWND hWnd)<br />
{<br />
HDC hdc = GetDC(hWnd); <br />
FILE * fp = NULL;<br />
fp = _wfopen(L"d:\\bmp.bmp",L"r+");<br />
int width,height; <br />
if (fp)<br />
{<br />
BITMAPFILEHEADER bmFileHeader;<br />
BITMAPINFOHEADER bmInfoHeader;<br />
PBYTE pBmData = NULL;<br />
fread(&bmFileHeader,sizeof(BITMAPFILEHEADER),1,fp);<br />
fread(&bmInfoHeader,sizeof(BITMAPINFOHEADER),1,fp);<br />
BITMAPINFO* pBmInfo;<br />
int size;<br />
<br />
if (bmInfoHeader.biBitCount == 24)<br />
{<br />
size = sizeof(BITMAPINFOHEADER);<br />
}<br />
else size = sizeof(BITMAPINFOHEADER) + 2 * sizeof(RGBQUAD);<br />
<br />
pBmInfo = (PBITMAPINFO)new BYTE[size];<br />
<br />
fseek(fp,sizeof(BITMAPFILEHEADER),SEEK_SET);<br />
fread(pBmInfo,size,1,fp);<br />
pBmInfo->bmiHeader.biHeight*= -1;<br />
width = pBmInfo->bmiHeader.biWidth;<br />
height = pBmInfo->bmiHeader.biHeight;<br />
<br />
<br />
pBmData = new BYTE[bmInfoHeader.biSizeImage];<br />
fread(pBmData,1,bmInfoHeader.biSizeImage,fp);<br />
fclose(fp);<br />
<br />
pBmInfo->bmiHeader.biClrImportant = 2;<br />
pBmInfo->bmiHeader.biClrUsed = 2;<br />
<br />
DWORD fdwInit = CBM_INIT;<br />
HBITMAP hBitmap = CreateBitmap(width,height,bmInfoHeader.biPlanes,bmInfoHeader.biBitCount,pBmData);<br />
DWORD err = GetLastError();<br />
<br />
BITMAP bitmap; GetObject(hBitmap,sizeof(BITMAP),&bitmap);<br />
<br />
HDC TmpDC = CreateCompatibleDC(hdc);<br />
BYTE *pbase;<br />
HBITMAP TmpBmp=CreateDIBSection(TmpDC,<br />
pBmInfo,DIB_PAL_COLORS,(void**)&pbase,0,0);<br />
HGDIOBJ TmpObj=SelectObject(TmpDC,TmpBmp);<br />
<br />
HDC dcBmp=CreateCompatibleDC(TmpDC);<br />
HGDIOBJ TmpObj2 = SelectObject(dcBmp,hBitmap);<br />
int ret = BitBlt(TmpDC,0,0,width,height,dcBmp,0,0,SRCCOPY);<br />
err = GetLastError();<br />
<br />
SelectObject(decBmp,TmpObj2);<br />
DeleteDC(dcBmp);<br />
TextOut(TmpDC,100,100,L"Watermark",lstrlen(L"Watermark"));<br />
<br />
DeleteObject(hBitmap);<br />
hBitmap=TmpBmp;<br />
DIBSECTION dib;<br />
GetObject(hBitmap,sizeof(DIBSECTION),&dib);<br />
<br />
<br />
SelectObject(TmpDC,TmpObj);<br />
DeleteDC(TmpDC);<br />
DeleteDC(hdc);<br />
delete []pBmData;<br />
delete []pBmInfo;<br />
<br />
}<br />
<br />
}<br />
Thanks
|
|
|
|
|