|
|
C++ is not the way.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Ah, i was so pathetically lame - cant stand myself. Shame on me!
if(buff[i] != '\n' && buff[i] != '\r')
{
temp[x] = buff[i];
x++;
}
Works perfectly. That was '\r' char unparsed which messed up everything.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
I'd expect a compiler error on the original code; single quotes mean a character is between them and \r\n is two characters.
If you still want to check for \r\n rather than for any occurence of \r separately, you could use something like this:
for (int i = 0; i < len; i++)
{
if(!(buff[i] == '\n' || (buff[i] == '\r' && i+1 < len && buff[i+1] == '\n')))
{
temp[x] = buff[i];
x++;
}
}
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Nope, there was no error. That was silly mistake
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
I suppose you do a HeapFree call somewhere, however
temp = (wchar_t *)HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
temp, sizeof(wchar_t *) * wcslen(temp) + 1);
is a bit dangerous. HeapReAlloc might return NULL, in which case you have no chance of freeing the memory since you're overwriting the only access you have to it.
You should always use a temporary pointer for the return value.
wchar_t* temp2 = (wchar_t *)HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
temp, sizeof(wchar_t *) * wcslen(temp) + 1);
if (temp2 != NULL)
temp = temp2;
else
Error handling and HeapFree temp pointer
|
|
|
|
|
Everything is under control :P There are memory checks outside of the function i posted here, and, it is not complete here (code was meant to just present en error situation). However, thank you for suggestions about HeapRealloc
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
I want to capture the desktop image behind my main window.I used
HDC hDesktopDC = GetDC(NULL);
RECT rect;
GetWindowRect(&rect);
......
BitBlt(hMemDC, 0,0, nWidth, nHeight, hDesktopDC, rect->left, rect->top, SRCCOPY);
hBitmap = (HBITMAP)SelectObject(hMemDC, hOldBitmap);
but, the image I got was my window,not Its background.
what's the matter?
How could I get the image behind my main window?
Thanks guys!
|
|
|
|
|
Hide your window first by calling ShowWindow(hwnd, SW_HIDE) .
|
|
|
|
|
thanks hans.
that would be fine,but there is always a flash.not perfect.
|
|
|
|
|
You can minimize your application window first and then get the hWnd to the desktop window using the GetDesktopWindow.[^]Then you can maximize your application back again.
I am a HUMAN. I have that keyword in my name........
_AnsHUMAN_
|
|
|
|
|
You could manipulate the clipping region for the desktop window before having it paint itself.
|
|
|
|
|
Dear All,
I have a main modeless dialogbox created by CreateDialog and have another child model dialog box created by DialogBox and on this child window I have many button but when I am clicking on any button WM_COMMAND is not getting fired in winproc of child dialog.
I will be very thankful for your support.
With regards
RYK
|
|
|
|
|
There is only a few reasons I can think of why this is happening:
1. Make sure you are looking in the right place for the message. I know it seems trivial, but it happens to everyone.
2. Make sure you set the right MsgProc for the child dialog.
3. Make sure something else isn't replacing the MsgProc for the child dialog (such as MFC)
Spy++ is distributed with Visual Studio, and can be found under the tools menu. Follow these steps to debug using Spy++.
Run your program and open the child dialog where the problems are
Start Spy++ from the Tools menu
Find your child dialog window, either in the list or using the find window toolbar icon
Right click on your child dialog window in the list and select Messages
Click some buttons in your program to see if they show up in the list
You can also check things like check the memory address of the MsgProc and window styles by selecting properties from the right click menu.
|
|
|
|
|
Hi
I'm working on an application that makes use of the MessageBox API. I've written the MessageBox API as:
MessageBox(NULL, sMsg, sTitle, MB_OK|MB_ICONEXCLAMATION|MB_TASKMODAL);
The issue I face is that sometimes when this message box comes on view, it disappears to the background shortly after it displays even though I've specified MB_TASKMODAL.
I replaced MessageBox with AfxMessageBox and the issue seems to be fixed. I no longer have the message box hiding behind other dialogs. I am planning to use AfxMessageBox for the project I am working on.
Could some let me know why this issue occurs and what difference between MessageBox and AfxMessageBox may have fixed the issue?
Thanks
Jens
|
|
|
|
|
MessageBox(NULL, sMsg, sTitle, MB_OK|MB_ICONEXCLAMATION|MB_TASKMODAL);
The first parameter means: "A handle to the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window". For AfxMessageBox you don't need to pass the windows handle.
So this, might be the cause but I might be wrong.
I am a HUMAN. I have that keyword in my name........
_AnsHUMAN_
|
|
|
|
|
AfxMessageBox is a modal dialog of the calling CWnd; MessageBox with a NULL hwnd is a modal dialog of the desktop. Hence, AfxMessageBox will always stay on top of your app, but MessageBox can be hidden by other windows. You can force MessageBox to have the same behavior by using m_hWnd for the first parameter.
|
|
|
|
|
Hans
From what I understand I can still continue using MessageBox by using m_hWnd as the first parameter. What should I declare m_hWnd as? Should it be just an HWnd? If so, what should it be initialized to?
|
|
|
|
|
In MFC, anytime you have any window (such as dialog, view, etc.), that window has a hwnd, which is accessible by the variable m_hWnd , which is declared to be HWND (which is what MessageBox wants).
|
|
|
|
|
A common value for a MFC application is AfxGetMainWnd()->m_hWnd .
AfxGetMainWnd() returns the value you set for m_pMainWnd in the YourApp::InitInstance() function. As the name suggests, it is the main application window.
If you are using it from inside a dialog, you may want to use the dialog HWND instead, although it is not necessary.
|
|
|
|
|
i have a Dialog and ListBox
i created a class to manipulate Controls: CControl
my class have function:
BOOL CControl::GetAllProcess(CListCtrl list1, int *arrProcId)
and in Dialog's function:
CControl ctr;
ctr.GetAllProcess(IDC_LIST1,arrProcId);
but can't convert int to CListBox
don't same CSharp
plz Help me...
very clearly if you have a example for me...thanks very much
sorry if my english isn't good
|
|
|
|
|
You have defined the function this way:
BOOL CControl::GetAllProcess(CListCtrl list1, int *arrProcId) but you are calling it this way:
ctr.GetAllProcess(IDC_LIST1,arrProcId); .
You can't convert from IDC_LIST1 to a CListCtrl; one is a numeric id, the other is a class. Look at the examples here on Codeproject about how to use the CListCtrl class. Basically, you need to use the resource editor to create a CListCtrl variable; a DDX statement will attach the CListCtrl variable to IDC_LIST1.
And you probably want to write the function like this:
BOOL CControl::GetAllProcess(CListCtrl& list1, int *arrProcId)
|
|
|
|
|
oh thanks for your help ..so much
|
|
|
|
|
You need to use GetDlgItem()[^] to get the window handle from the control ID.
If this is called from within a CWnd derived class this will return a CWnd object which can be cast to the list control. See CWnd::GetDlgItem()[^]
Also, window classes are generally passed around as pointers. At a very minimum they should be passed as a reference as Hans suggested.
Passing by value will create a copy of the class. Properties changed in the copied class may not reflect back on the original.
BOOL CControl::GetAllProcess(CListCtrl *list1, int *arrProcId) {
}
CControl ctr;
ctr.GetAllProcess(GetDlgItem(IDC_LIST1), arrProcId);
|
|
|
|
|