|
I have been following this thread and I think you are painting yourself into a corner. You could make this so much easier for yourself by using the standard messages and notifications available to a dialog and its child controls.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
well sir, i am just learning and doing work. i don't have much idea about it. so i request for help. i am trying this from all most a week. i google it and did not found simillar to what i am looking for. maybe because i don't have enough knowledge. so..
hoping to get help from some kind heart.
|
|
|
|
|
Member 2119844 wrote: hoping to get help from some kind heart. Which is what I offered to you yesterday. Use the features of the CDialog and its controls rather than struggling to try and interpret individual keystrokes that are already captured for you. Text boxes have events that you can capture as characters are entered into them, which allow you to check and/or modify their content. The CDialog class has a function that will capture or refresh all the data between the dialog and the associated class variables etc.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Dear sir, i really appreciate your and Santhosh suggestion. i do. but the thing is bit difference what i am looking for. maybe i am not able to describe very well, what i am looking for. sorry for that. because my English is not good enough. so please don't get me wrong. once again i am trying to explain what i need to do. and what i come up to.
i need to make function that return value after press Enter key. not directly and not in any other way. but from function when it call from outer class.
this is the event when user press button in dlg class.
void CRetValTestDlg::OnGetString()
{
m_TxInput.InFlag = false;
CString s = m_TxInput.GetString();
m_TxOutput.SetWindowText (s);
}
and this is CMyTextBox calss member function which is call from dlg class on button press. which need to return value.
CString CMyTextBox::GetString()
{
if (InFlag == true)
return RetVal;
return "";
}
now i have come upto this
CString CMyTextBox::GetString()
{
while (InFalg != true) {
DoEvents(); if (InFlag == true) return RetVal; }
return ""; }
this is work. but when i use While and DoEvents the processor took lot of work. it took all most 50% of CPU used. and which is really not good. i think. and some time it does not come out from that loop when user left so when the program close. it remain in task manager. and CUP running.
now What i am looking for is -> is there any other way to wait till event. maybe using CEvent or CallBack or threading or something else. without using lot of CPU used. because i don't know anything about them. i have never use.
CString CMyTextBox::GetString()
{
if (InFlag == true)
return RetVal;
return "";
}
i hope this time i could able to tell what i need for. this is really important for me.
so Please Please Help.
|
|
|
|
|
All I can do is repeat what I said before. Use the events and notifications of the CDialog class. The default action when user presses the enter key is to call the OnOK() function. You add code to that method to capture the text using the UpdateData() function. Let the dialog do the work for you. Maybe you should spend some time reading the documentation about Dialog Boxes[^] in general, and the CDialog [^] class in particular. You may also find that the documentation is available in your own language.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
ok i will try. but.
as you said. >> Use the events and notifications of the CDialog class.
Which Events and Notification?
i use this to block call OnOk() while press Enter Key.
BOOL CRetValTestDlg::PreTranslateMessage( MSG* pMsg )
{
if (pMsg->message == WM_KEYDOWN)
{
if ((pMsg->wParam == VK_RETURN) || (pMsg->wParam == VK_ESCAPE))
pMsg->wParam = NULL; }
return CDialog::PreTranslateMessage( pMsg );
}
how dialog do my work.
it would be great if i could get some sample code.
i have spend lot of time to read and search. i did not find or i did not understand. so i request for help. if i understand, i may not request for help.
|
|
|
|
|
I don't know what you are hoping to achieve with the code above, but it is not likely to help you. Please spend some time reading the two links I gave in my previous answer, so you understand how dialogs operate.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
|
By default, a dialog's OnOK() handler will be called when you "press" the Enter key from within an edit control. If you would rather the edit control do something else, check out the ES_WANTRETURN style.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
char buffer[50]
int offset =3;
char Buffer[250];
sprintf_s(&buffer[offset],offset,"%s",Buffer);
When we use the above funcation and application crashed with the folloing message
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!
Program: xyz.exe
File: f:\dd\vctools\crt_bld\self_x86\crt\src\vsprintf.c Line: 244 Expression: ("Buffer too small", 0)
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
---------------------------
Abort Retry Ignore
---------------------------
OS used : Windows 7 32bit OS
Microsoft Visual Studio 2008 (VC++)
Version 9.0.30729.1SP
|
|
|
|
|
Second parameter of sprintf_s is the size of destination buffer.
If length of formatted string is greater than the size of source buffer, sprintf_s will create debug assertion.
If length of string in Buffer is less than 3, then it will not create an debug assertion.
Here you can change the second parameter of sprintf_s to 47,by considering offset in buffer.
|
|
|
|
|
char buffer[50]
int offset =3;
char Buffer[250];
OR
char buffer[50]
int offset =3;
char Buffer[50];
Is working fine with VS6.0, but when the same code is compiled with VS2008 I am still getting the same error as mentioned above.
|
|
|
|
|
Which function is used in VC6.0 ? Is it sprintf() or sprintf_s() ?
If it is sprintf(), then nothing to wonder, becausee sprintfdoesnot check the output buffer size.
|
|
|
|
|
Member 9353776 wrote: sprintf_s(&buffer[offset],offset,"%s",Buffer);
Here you are stating your destination buffer has size 3 (parameter 2 of sprintf_s (see MSDN[^]). If the source buffer (namely Buffer ) contains a string with more than 3 characters then you get the assertion.
Veni, vidi, vici.
|
|
|
|
|
char buffer[50]
int offset =3;
char Buffer[250];
OR
char buffer[50]
int offset =3;
char Buffer[50];
Is working fine with VS6.0, but when the same code is compiled with VS2008 I am still getting the same error as mentioned above.
|
|
|
|
|
Short answer: You sprintf statement is plain wrong if 'it is working fine' maybe by accident.
Somewhat longer answer: If you have a 50 bytes buffer, why don't you pass 50 instead of 3 ? Why are you using the misleading name offset for passing a size?
Veni, vidi, vici.
|
|
|
|
|
First thing is that, trust the implementation made by Microsoft. This is a very primitive function and you will have to read the documentation first.
Second you can your strcpy_s or strcat_s (if you're concatenating). sprint_s is not really a choice string copy.
Third your strings must be null terminated.
To understand this better, I am illustrating this with a code example
char buffer[12]= {0};
int offset =3;
char Buffer[50] = "Hello World";
sprintf_s(buffer,sizeof(buffer), "%s", Buffer);
in the above example buffer has 12 character in legnth and Hello World String contains 11 characters + null terminated. Anything less than 12 character size will raise assertion buffer too small. for sprintf_s only the number of characters being copied only matters. not really the original size of the buffers.
-Sarath.
Rate the answers and close your posts if it's answered
|
|
|
|
|
I have fixed the issue,
I am very much thankful to all your replies
|
|
|
|
|
I can just find the BIOS offset(0xFE000)using SMBIOS structures,but do not know the detail of the info it disp in WinHex tool.
|
|
|
|
|
Take a look at some of these links[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hello. I'm currently extending an options risk application that makes use of Gunnar Bolle's neat little charting control. I'm trying to get a handle on the functionality by looking at the code but it would GREATLY speed things up if I could communicate with someone who is versed in the control. What I need to do is pretty basic; labeling, editing, scaling, etc. Any help would be greatly appreciated.
|
|
|
|
|
You could try posting a message in the forum at the end of the article so he sees it.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I already tried that. I'm thinking of putting out an international APB.
|
|
|
|
|
I have the follow code :
CSize sizeDoc = pDoc->GetBitmapSize();
CDC MemDC, TempDC;
MemDC.CreateCompatibleDC(pDC);
TempDC.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = MemDC.SelectObject(&pDoc->GetBitmap());
pDC->SetStretchBltMode(HALFTONE);
TempDC.StretchBlt(0, 0, sizeLog.cx, sizeLog.cy, &MemDC, 0, 0, sizeDoc.cx, sizeDoc.cy, SRCCOPY);
pDC->StretchBlt(0, 0, sizeLog.cx, sizeLog.cy, &TempDC, 0, 0, sizeDoc.cx, sizeDoc.cy, SRCCOPY);
pDC->SelectObject(pOldBitmap);
and on view I see nothing ... what I'm doing wrong ? TempDC don't have the same structure like MemDC ? Because if I do so:
CSize sizeDoc = pDoc->GetBitmapSize();
CDC MemDC, TempDC;
MemDC.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = MemDC.SelectObject(&pDoc->GetBitmap());
pDC->SetStretchBltMode(HALFTONE);
pDC->StretchBlt(0, 0, sizeLog.cx, sizeLog.cy, &MemDC, 0, 0, sizeDoc.cx, sizeDoc.cy, SRCCOPY);
pDC->SelectObject(pOldBitmap);
everything it's ok ...
|
|
|
|
|
CSize sizeDoc = pDoc->GetBitmapSize();
CDC MemDC, TempDC;
MemDC.CreateCompatibleDC(pDC);
TempDC.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = MemDC.SelectObject(&pDoc->GetBitmap());
pDC->SetStretchBltMode(HALFTONE);
TempDC.StretchBlt(0, 0, sizeLog.cx, sizeLog.cy, &MemDC, 0, 0, sizeDoc.cx, sizeDoc.cy, SRCCOPY);
pDC->StretchBlt(0, 0, sizeLog.cx, sizeLog.cy, &TempDC, 0, 0, sizeDoc.cx, sizeDoc.cy, SRCCOPY);
pDC->SelectObject(pOldBitmap);
When a memory device context is created, GDI automatically selects a 1-by-1 monochrome stock bitmap for it. GDI output functions can be used with a memory device context only if a bitmap has been created and selected into that context.
Here TempDC is not attached to any Bitmap, and therefore GDI function StretchBlt will not draw to TempDC.
You have to create a Bitmap compatible to your DC, and attach the same to temperory memory DC.
CSize sizeDoc = pDoc->GetBitmapSize();
CDC MemDC, TempDC;
MemDC.CreateCompatibleDC(pDC);
TempDC.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = MemDC.SelectObject(&pDoc->GetBitmap());
pDC->SetStretchBltMode(HALFTONE);
HDC hdc = ::GetDC(NULL);
HBITMAP hScreenBmp = CreateCompatibleBitmap( hdc , nWidth, m_nImageHeight );
TempDC.SelectObject( hScreenBmp );
TempDC.StretchBlt(0, 0, sizeLog.cx, sizeLog.cy, &MemDC, 0, 0, sizeDoc.cx, sizeDoc.cy, SRCCOPY);
pDC->StretchBlt(0, 0, sizeLog.cx, sizeLog.cy, &TempDC, 0, 0, sizeDoc.cx, sizeDoc.cy, SRCCOPY);
pDC->SelectObject(pOldBitmap);
|
|
|
|
|