|
yes,now that works.
what if i want to write the new value in the edit box in newline.now all the data are written in single line.
|
|
|
|
|
Append \r\n in the string where you want a line break
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
i tried f<<endl .that worked.Thanks...
|
|
|
|
|
projectip wrote: f.write((LPCTSTR)str,10);
I think this statement makes the problem. give proper length of the source buffer. If the string length less than 10, this problem may occur.
Please try with this.
f.write((LPCTSTR)str,str.GetLength());
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
projectip wrote: f.write((LPCTSTR)str,10);
Why the unnecessary cast?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I followed this link for embedding manifest in the exe.
http://msdn.microsoft.com/en-us/library/bb756929.aspx
I could see RT_MANIFEST markup in the exe(using resourcehacker).
But yesterday when i rebuilt my application (both in vista and windows 2003 server) i am not able to see RT_MANIFEST markup in the exe. Instead i saw a number 24 under that my manifest file is there.
Are some settings changed? I am not able to figure it out. Can any one help me?
Regards
|
|
|
|
|
Did you change the build order from Unicode?
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
|
When drawing a bitmap, I want to draw it with a new alpha value as below. Do I have to clone a bitmap and make changes pixel by pixel?
DWORD Gray1000=pClr->GetRed()*299+pClr->GetGreen()*587+pClr->GetBlue()*114;
BYTE newAlpha=BYTE(Gray1000/1000);
system
|
|
|
|
|
If it is a replace a single color .You can do raster operations.
else create a platte and store the color reference tables.And update the color by pixcel wise.
Help:
HBITMAP GlobalBlitReplaceColor (HBITMAP hBmp,COLORREF cOldColor,COLORREF cNewColor,HDC hBmpDC)
{
HBITMAP RetBmp=NULL;
if (hBmp)
{
HDC BufferDC = CreateCompatibleDC(NULL); // DC for Source Bitmap
if (BufferDC)
{
HBITMAP hTmpBitmap = (HBITMAP) NULL;
if (hBmpDC)
{
if (hBmp == (HBITMAP)GetCurrentObject(hBmpDC, OBJ_BITMAP))
{
hTmpBitmap = CreateBitmap(1, 1, 1, 1, NULL);
SelectObject(hBmpDC, hTmpBitmap);
}
}
// here BufferDC contains the bitmap
HGDIOBJ PreviousBufferObject = SelectObject(BufferDC,hBmp);
HDC DirectDC=CreateCompatibleDC(NULL); // DC for working
if (DirectDC)
{
HDC MaskDC=CreateCompatibleDC(NULL); // DC for mask
if (MaskDC)
{
// Get bitmap size
BITMAP bm;
GetObject(hBmp, sizeof(bm), &bm);
// create a BITMAPINFO with minimal initilisation for the CreateDIBSection
BITMAPINFO RGB32BitsBITMAPINFO;
ZeroMemory(&RGB32BitsBITMAPINFO,sizeof(BITMAPINFO));
RGB32BitsBITMAPINFO.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
RGB32BitsBITMAPINFO.bmiHeader.biWidth = bm.bmWidth;
RGB32BitsBITMAPINFO.bmiHeader.biHeight = bm.bmHeight;
RGB32BitsBITMAPINFO.bmiHeader.biPlanes = 1;
RGB32BitsBITMAPINFO.bmiHeader.biBitCount = 32;
RECT tmprect = {0,0,bm.bmWidth,bm.bmHeight};
// creating the Monochrom bitmap with existing bitmap dimmensions
HBITMAP bitmapTrans = CreateBitmap(bm.bmWidth,bm.bmHeight,1,1,NULL);
DeleteObject(SelectObject (MaskDC,bitmapTrans));
SetBkColor(BufferDC,cOldColor);
RetBmp = CreateBitmap(bm.bmWidth,bm.bmHeight,1,32,NULL);
HGDIOBJ PreviousObject = SelectObject (DirectDC,RetBmp);
HBRUSH sb = CreateSolidBrush(cNewColor);
FillRect(DirectDC,&tmprect,sb);
DeleteObject(sb);
//Computing the raster operations on Bitmap to load the colors dynamically into bitmap
BitBlt(MaskDC, 0, 0, bm.bmWidth, bm.bmHeight, BufferDC, 0, 0, SRCCOPY);
BitBlt(DirectDC, 0, 0, bm.bmWidth, bm.bmHeight, BufferDC, 0, 0, SRCINVERT);
BitBlt(DirectDC, 0, 0, bm.bmWidth, bm.bmHeight, MaskDC, 0, 0, SRCAND);
BitBlt(DirectDC, 0, 0, bm.bmWidth, bm.bmHeight, BufferDC, 0, 0, SRCINVERT);
// releasing the memory
DeleteObject(PreviousObject);
DeleteObject(bitmapTrans);
DeleteDC(MaskDC);
}
// clean up
DeleteDC(DirectDC);
}
// BufferDC is now useless
if (hTmpBitmap)
{
SelectObject(hBmpDC, hBmp);
DeleteObject(hTmpBitmap);
}
SelectObject(BufferDC,PreviousBufferObject);
DeleteDC(BufferDC);
}
}
return RetBmp;
}
|
|
|
|
|
followait wrote: Do I have to clone a bitmap and make changes pixel by pixel?
You do if you don't wan't to change the original bitmap.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Guys i have just made a winsock programme(console mode).
It is a simple programme in which the client software
displays the text inputted in the server programme
using the function cin.getline().Now i want to make a chat programme
conlose mode.But i tried to use the send() function in the
client software but it is not working,so how can the two programme
chat wuth each other.My main point is that i am trying to maje chat
programme can anybody tell me some god tutirial or give me some guideline
|
|
|
|
|
|
Hello,
How do I grab the info where the mouse is so I can determine the position of the mouse when clicked over a certain region of the screen (say, over a certain part of a bitmap)?
I'm creating a dialog based app.
thanks!
|
|
|
|
|
The button down/up messages have the coordinates encoded in the LPARAM.
There's also GetCursorPos().
Mark
|
|
|
|
|
|
Note that there is an important difference between the two ways Mark gave you to get the mouse position. The position associated with the window message may be different than the one you get from GetCursorPos() -- the former is the one at the time the message was sent, the latter is the mouse's position at the time of the call. If your application is very busy, the two values can be very different. You likely want the position associated with the message:
GetCurrentMessage() -> pt Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> 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! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hi,
I am facing crash problem with debug version of executable. I have ported C++ code from VS6.0 to VS.Net2003. In VS6.0 both Debug and Release version executable works fine. But in VS.Net2003 it is crashing with debug version where as works fine with release version. It is Multithreaded C++ Code.
Executable crashed with fgetc() function. The particular call stack looks like
msvcr71d.dll!_heap_alloc_base(unsigned int size=4132) Line 211 C
msvcr71d.dll!_heap_alloc_dbg(unsigned int nSize=4096, int nBlockUse=2, const char *
szFileName=0x1026a03c, int nLine=58) Line 397 + 0x9 C
msvcr71d.dll!_nh_malloc_dbg(unsigned int nSize=4096, int nhFlag=0, int nBlockUse=2, const char * szFileName=0x1026a03c, int nLine=58) Line 260 + 0x15 C
msvcr71d.dll!_malloc_dbg(unsigned int nSize=4096, int nBlockUse=2, const char *
szFileName=0x1026a03c, int nLine=58) Line 176 + 0x1b C
msvcr71d.dll!_getbuf(_iobuf * str=0x1027c8b8) Line 58 + 0x13 C
msvcr71d.dll!_filbuf(_iobuf * str=0x1027c8b8) Line 120 + 0x9 C
msvcr71d.dll!fgetc(_iobuf * stream=0x1027c8b8) Line 48 + 0x41 C
It got crashed in HeapAlloc() function with exception "Unhandled exception at 0x7c9114b6 in TestCrash.exe: 0xC0000005: Access violation writing location 0x003aba9d".
Can anyone help please?
|
|
|
|
|
There's 2 big differences between Release and Debug in this case, _malloc_dbg which you can see in your stack trace is a good deal more complex than the malloc that gets called in Release, it does a lot more checking and the allocations it creates have extra debug headers, about 20 bytes per alloc if I remember rightly, so you could have an issue of overlapped buffers or a fixed buffer being overflowed for example which only shows up in Debug. Usually that wouldn't cause an Access violation directly but it's possible. VC6 code is less robust and may not pick up the error and fall over trying to report it which would be what is happening in VS 2003. Much more likely is the second difference, Debug code is slower ~30% slower than Release and in VS.Net2003 may also be doing extra inline stack verification, exception management and security stuff on each call. It's only a guess but I would shoot for you having a marginal sychronisation problem in your code which has never showed up before. Probably only shows when some part of the code is really slow compared to another. You need to check all your shared (between threads) variables, especially any shared memory allocated on the heap.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
I'm writing a .DLL that's being used in both our Client and Server application. Is there a windows call I can use that will tell me if the current process is running as a windows service or not?
Thnx.
M.
|
|
|
|
|
Can't you use GetCurrentUser? I'm pretty sure that a service will default to LocalSystem, or such.
I'm also pretty sure that it can do clever things like ImpersonateUser, etc, but you can't cover everything!
Lastly, doesn't a service run from a different context, so GetDesktopWindow would fail?
While not a black and white answer for you, I hope that helped.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Use a flag which you can control.
Greetings from Germany
|
|
|
|
|
Mike Doner wrote: Is there a windows call I can use that will tell me if the current process is running as a windows service
You can check whether one of the parent processes of this process is services.exe , user services are created via this process.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
I would like to store pointers to class member functions in an array (e.g. CTypedPtrArray) but I am having difficuly declaring, initialising and calling the functions. All functions are void fn(void) and are non-static.
Can anyone help please?
|
|
|
|
|
Not really a good answer for you...
Pointers to member functions are nothing like a standard pointer, so it's unlikely you'll succeed. After all, they're really two pointers - they need a "this" pointer encoded also.
For an article that may help, I did a search for "member function pointer" on google, and this came up first:
Member Function Pointers and the Fastest Possible C++ Delegates[^]
A comprehensive tutorial on member function pointers, and an implementation of delegates that generates only two ASM opcodes!
Enjoy!
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|