|
Hi guys...
Suppose I have selected the text in a rich edit control through( Ctrl + A) or mouse click and move, after I have only clicked on either selected or non-selected area, I want to deselect this text. It' look like deselected, but when I called GetSel() it gave me the starting and end selection point.
Thanks in advance.
|
|
|
|
|
You can use m_RichEdit.SetSel(0, 0); to deselect any selected text.
|
|
|
|
|
Hey. Basically I made a program that contains 17 * 7 number of boxes using two for loops, and they seem to work pretty well, until i resize it. Every single time i resize the window, the memory goes up by quite a bit, until the program fails with too much memory. I am pretty sure i deleted everything that i called for WM_PAINT, but I am not sure what other parts i might have overlooked. Is there any common mistakes that people would make for drawing a lot of GDI objects? Do I need to post my code to see which part went wrong?
here are the codes. sorry for asking the stupid question "do i need to post my code here" =_+;;
#include <windows.h>
COLORREF color[17][7];
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg ;
HWND hwnd;
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.lpszClassName = TEXT( "Window" );
wc.hInstance = hInstance ;
wc.hbrBackground = GetSysColorBrush(COLOR_INACTIVECAPTIONTEXT);
wc.lpszMenuName = NULL;
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
RegisterClass(&wc);
hwnd = CreateWindow( wc.lpszClassName,TEXT("BOXES"), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 800, 800, NULL, NULL,
hInstance,
NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while( GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
int i_row, j_column;
switch (msg)
{
case WM_CREATE:
{
for(i_row=0; i_row<17; i_row++)
{
for(j_column=0; j_column<7; j_column++)
{
color[i_row][j_column]=RGB(255,255,255);
}
}
break;
}
case WM_PAINT:
{
HDC hdc;
PAINTSTRUCT ps;
HPEN hPen,holdPen;
HBRUSH hBrush_1, holdBrush;
hdc = BeginPaint(hwnd, &ps);
hPen = CreatePen(PS_NULL, 1, RGB(0, 0, 0));
holdPen = SelectObject(hdc, hPen);
for(i_row=0; i_row<17; i_row++)
{
for(j_column=0; j_column<7; j_column++)
{
hBrush_1 = CreateSolidBrush(color[i_row][j_column]);
holdBrush = SelectObject(hdc, hBrush_1);
Rectangle(hdc, 90*j_column+100, 50+30*i_row, 90*j_column+180, 30*i_row+75);
}
}
DeleteDC(hdc);
DeleteObject(hPen);
DeleteObject(holdPen);
DeleteObject(hBrush_1);
DeleteObject(holdBrush);
EndPaint(hwnd, &ps);
break;
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
modified on Wednesday, March 9, 2011 5:01 AM
|
|
|
|
|
leorex wrote: Is there any common mistakes that people would make for drawing a lot of GDI objects?
maybe you are leaking handles/GDI objects? If the memory usage increases a lot, possibly you are creating bitmaps that never get freed up?
leorex wrote: Do I need to post my code to see which part went wrong?
that usually helps a lot, otherwise we can only guess. This is like as if you had a problem with your car so you'd call your mechanic and say "my car's engine is smoking, do i actually need to show you the car to get it fixed?".
In case you do decide to show code, only the relevant parts, please, and use <pre> </pre> tags to make it nicely formatted and readable.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
leorex wrote: Do I need to post my code to see which part went wrong? Yes.
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]
|
|
|
|
|
What are you doing in your WM_SIZE handler?
|
|
|
|
|
I have updated the thread and posted my code there. Please point out the part where i went wrong tyvm
|
|
|
|
|
Please put your code between <pre></pre> tags (use the code block button), so it retains its formatting.
I must get a clever new signature for 2011.
|
|
|
|
|
your code is hard to read without proper formatting (pre tags are your friends ), but as i see it here:
leorex wrote: for(i_row=0; i_row<17; i_row++) { for(j_column=0; j_column<7; j_column++) { hBrush_1 = CreateSolidBrush(color[i_row][j_column]); holdBrush = SelectObject(hdc, hBrush_1); Rectangle(hdc, 90*j_column+100, 50+30*i_row, 90*j_column+180, 30*i_row+75); //rember is x, y, x, y
} }
you create a new brush in every iteration, but you will delete only the very last one, all the rest just leaks away happily. Also, in every iteration you overwrite the value of holdbrush , thus, unless you make exactly 1 iteration, you won't know the original brush and won't be able to select it back into the DC when you are done.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
PROBLEM SOLVED!!!
close to no memory leak with this in the for loop (still goes up by like a few bytes once in a while >.< but it doesnt really interfere with the program so i guess its ok =_=)
hBrush_1 = CreateSolidBrush(color[i_row][j_column]);
SelectObject(hdc, hBrush_1);
Rectangle(hdc, 90*j_column+100, 50+30*i_row, 90*j_column+180, 30*i_row+75);
DeleteObject(hBrush_1);
to be perfectly honest I do not get the explanation with holdbrush.
"you won't know the original brush and won't be able to select it back into the DC when you are done."
sorry if it is a neeeewb question, but why?
|
|
|
|
|
That solution looks better, but now you are deleting the brush while it is still selected into the DC, that is not healthy.
If i were you i'd just store the original brush somewhere in the beginnings (before the for loops...) and then use it along.
HBRUSH holdBrush = GetCurrentObject(hdc, OBJ_BRUSH);
...
hBrush_1 = CreateSolidBrush(color[i_row][j_column]);
SelectObject(hdc, hBrush_1);
Rectangle(hdc, 90*j_column+100, 50+30*i_row, 90*j_column+180, 30*i_row+75);
SelectObject(hdc, holdBrush);
DeleteObject(hBrush_1);
...
Well, about the other thing, i will try to explain. When you use SelectObject, it will return the handle to the previously selected tool of given type. So if you do this (example):
HBRUSH brush1 = CreateBrush...;
HBRUSH brush2 = CreateBrush...;
HBRUSH brush3 = CreateBrush...;
HBRUSH holdBrush = SelectObject(dc, brush1);
...draw...
holdBrush = SelectObject(dc, brush2);
...draw....
holdBrush = SelectObject(dc, brush3);
...draw....
SelectObject(dc, holdBrush);
DeleteObject(brush1);
DeleteObject(brush2);
DeleteObject(brush3);
...
In your code you did something similar in the loop, in every iteration you put the brush created in the previous iteration into holdBrush, the original, very first brush handle you should use in the end for the DC to perform the cleanup gets lost.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
U R LEGEND. I think I am getting it
|
|
|
|
|
Thanks. I think.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
Your code leaks like a submarine with a screen door .
1) you never SelectObject() the old objects back and thus lock the object from getting deleted. i.e. You need to SelectObject(hDC, hOldPen) before you can delete it. Or maybe your delete order takes care of that. Maybe, maybe not.
2) either way, why are you deleting hOldPen? that ain't yours to delete.
3) you create h_Brush1 17 x 7 times and never delete them except for 1 and you never select back holdBrush.
Basically for EVERY GDI object you need to do:
create
save old one
select new one
do whatever
select old one
delete new one
you should do that 17 x 7 times in your loop.
|
|
|
|
|
I want to put a image on client area of main frame windows of MDI project(MFC).
Please give me some idea for do this
|
|
|
|
|
|
|
hello guys.. I am trying to make a small scale IVR which should be able to detect that which key was pressed from the caller. I dont know from where to start. Any kind of resources on web (site links, pdf/ppt file or some forum for beginners) would be appreciated.
|
|
|
|
|
what is IVR ?
Watched code never compiles.
|
|
|
|
|
I'd guess this[^].
Press 5 if you liked this answer.
If you are using a rotary phone, then hang up and think about upgrading from the 1970's.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
ROFL! Excellent. I press 5.
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|
|
Hi there,
If you're familiar with .NET, try VBVoice. VBVoice integrates with Microsoft Visual Studio and combines an easy-to-use visual call flow environment with fully programmable controls. It comes with a prompt library (English (UK & US), French, German, Italian, Japanese, Spanish (Castilian & South American) and sample applications to help you get started (tons of VB6, C# and VB.NET sample applications; e.g. help desk, speech attendant, fax service, predictive dialer, etc.)
You can download the full version of VBVoice for free here http://pronexus.com/index.php/software/download-free-ivr-software/[^]
Hope that helps
|
|
|
|
|
Hi there...
Thanx for your answer and sorry for late reply if you get this message.
Do I need to get/buy any other extra hardware for this VBVoice to work?
I read about this before posting the question and I think we need to buy some kind of voice modem for this.
I just want to handle DTMF and an extra voice modem??...ehem ehem.
|
|
|
|
|
You are correct, you will require telephony media to connect the VBVoice application to the telephony infrastructure; VBVoice works with Dialogic media for the telephony connection. The Dialogic API integrates with VBVoice natively, so there is no extra programming required, in fact, once you have installed the Dialogic media and driver, you just select the media type in a VBVoice configuration; so the functions that VBVoice and Dialogic use to connect calls is really transparent to the programmer (and the caller).
You will need to determine the telephony protocol that will be available to the VBVoice/Dialogic IVR. This could be analog, T1 or E1 digital protocol, or even VoIP.
With analog and T1/E1 protocols you will required a Dialogic board/card, which comes as PCIU or PCI-Express (as you require). The Dialogic board in these cases have the resources required to conect a voice call, process DTMF, and additional features such as fax, conference, and speech recognition resources which are hardware-based, meaning the ability or resources are provided by the chipset of the Dialogic board. VBVoice taps into these resources to provide the funtionality to the application. The Dialogic board also facilitates the physical connection to your PBX or Telco which is providing the analog, or T1/E1 circuit.
In contrast, the Dialogic VoIP solution; Host Media Processing or HMP, does not require any Dialogic media board. Instead, the resources used to connect calls, process dtmf, fax, etc. is provided through specific Dialogic HMP licensing you purchase. The physical connection is the primary Network Interface Card of the IVR, and all call processing is done on the CPU of the server.
The advantages of a VoIP solution are that you can purchase a physically smaller server, such as a 1U rack server, since there is no requirement for a PCI board. The Dialogic PCI boards are all full length PCI boards, so are rather large. This is the case with all Dialogic boards we support, with the exception of the D4PCI boards which are half-length. Another benefit is that you only purchase the resources you need. Dialogic has a minimum initial order requirement of 4 channels, but you can increment this up at a later time as demand increases. Plus, you only buy the resources you need, so if you don't need speech recognition you would not buy the required Dialogic resource with HMP... if you purchase a PCI card, it may have the hardware-based resources which you will not neccessarily use in the application.
We have a list of the various Dialogic cards that VBVoice supports here: http://pronexus.com/index.php/services/support/supported-voice-cards/
If you have a particular protocol in mind, and a number of channels that the IVR will need to handle at any given time, I can provide some further advice on which Dialogic card would address your requirements.
|
|
|
|
|
can any one explain about the memory mapping of file what it does actually and how to use it...
please provide a example........
thanking you
sarfaraz
|
|
|
|
|