|
ThatsAlok wrote:
Let the str is DDX variable of your Edit Box.
Now Let you have updated your edit box with 123.
i.e. this way
str="123";
this->UpdateData(FALSE);
now you want to concatenate the 34 in that box
call
UpdateData(TRUE);
str+="34";
//again update the values
UpdateData(FALSE);
Alok,
Don think i'm bashing at your reply. But the suggestion you gave does not follow any standards of MFC dialog based programming. Just to retrieve a variable and update it back again you are calling UpdateData three times !!!. This can have serious consiquences, since all other CDialogs variables are also effected by this, which will not be desired at most time.
suhredayan There is no spoon.
|
|
|
|
|
suhredayan® wrote:
Don think i'm bashing at your reply
No Buddy, No hard feeling critisism helps in improving Programming!, you are always always welcome to correct me when ever i am wrong!
suhredayan® wrote:
Just to retrieve a variable and update it back again you are calling UpdateData three times !!!.
I just given a small overview how to solve the problem. anyway we can use GetWindowText too or raw apis like GetDlgItem*
suhredayan® wrote:
This can have serious consiquences, since all other CDialogs variables are also effected by this, which will not be desired at most time.
Yeah, you are 100% correct! How Silly i am
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
You have a lot of different solutions...
Are the two 'values' you are speaking purely value (no string I mean) ? And the 'output' is expressed as a string or still a value ??
If these are string, you can use the strcat function.
If these are integers, a solution would be to find out the number of digits used by the second value, then multiply the first value by 10 power this number and then finally add the second number to the previous result:
34 -> 2 digits (10^2 = 100)
123 * 100 = 12300
123 + 34 = 12334 (the number you wanted)
To find the number of digits, use the following algorithm:
int digits = ceil(log(10,Value));
Hope this helps
|
|
|
|
|
You can convert a number to a string with _itoa (for integers look MSDN for other types) or with the Format member of the CString class:
int number = 123;
CString s;
s.Format("%d", number);
Then you concatenate the strings and convert the result back, for example with _atoi.
Hope this helps.
MS
|
|
|
|
|
hello,
what i have is a list of all open windows and running processes. i have a hwnd to each window and its processid. all what i need - i thought.
my problem is, i want to list all running tasks in a listbox and show each window´s icon in the listbox... but how to get the icon? i used attached the handle to the window with an CWnd and called hIcon = pWnd.GetIcon(true); - after that i detached that handle from the CWnd... but it only work at 2 apps ;o) so: how to get ann icon of another running process/window???
i searched the net all the night and didn´t found any interesting articles...
cheers,
vertex_x
|
|
|
|
|
AfxGetInstance...()->LoadIcon()
i don't remember exactly the fisrt function name, but it might be something like this...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
you ment AfxGetApp()? that works only on your own created process as far as i know... i don´t know a way to do something linke CWnd::AfxGetApp()->... also ::AfxGetApp is no function in the global namespace...
thanks 4 reading ;o)
cheers,
arné
|
|
|
|
|
hum, yes your right...
what about LoadModule() ? (or smthing similar ? )
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Check out for this api
[ExtractIcon]
"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 get nice results by using SendMessage with WM_GETICON. If that is invalid there is always GetClassLong with an index of GCL_HICON.
HICON icon;
icon = (HICON) ::SendMessage(hwnd, WM_GETICON, ICON_SMALL, 0);
icon = (HICON) ::GetClassLong(hwnd, GCL_HICON);
|
|
|
|
|
thats it! thanks a lot! )
hIcon = (HICON)::SendMessage(hwnd, WM_GETICON, ICON_BIG, 0);
if(hIcon == NULL)
hIcon = (HICON)::GetClassLong(hwnd, GCL_HICON);
if(hIcon == NULL)
hIcon = (HICON)::GetClassLong(::GetParent(hwnd), GCL_HICON);
works - no just looking when hIcon is still NULL, if there is a ICON_SMALL )
cheers and thanx
vertex_x
|
|
|
|
|
thanks friend this helped me too...
|
|
|
|
|
Hi guys
I am facing a problem on how to make the Bitmap Added without disappearing when i minimize or maximize screen or just moving the program. My Bitmap graphics always disappear, i do not know how to use UpdateWindow Function to prevent this from happening can i have any demo projects that can guide me through this problem
Thank You
|
|
|
|
|
Hi,
Did you tried to redraw the bitmap window?
In your OnPaint() function try : m_BitmapWindow.RedrawWindow();
Regards,
Eli
|
|
|
|
|
I did not use OnPaint Function to create the bitmaps
I created a ShowBitmap(int x, int y, int type) function and some parameters for displaying the Bitmap, so what kind of other Functions would you recommend for me? Can UpdateWindows() be use?
|
|
|
|
|
I did not use OnPaint Function to create the bitmaps
I created a ShowBitmap(int x, int y, int type) function and some parameters for displaying the Bitmap, so what kind of other Functions would you recommend for me? Can UpdateWindows() be use?
|
|
|
|
|
Sorry what are the requirements i need to do before using this m_Bitmap.RedrawWindow();
Should i declare CDC m_Bitmap or CBitmap m_Bitmap?
|
|
|
|
|
Hi everybody, I am developing an Browser Helper Object. I want to get the data sent by the POST method on the NavigateComplete event. How can I do that? Hope to see your reply soon! Thanks.
|
|
|
|
|
Hello Everyone,
Can someone please tell a way to create tracking tooltip. Please note I have already tried the MSDN Libary tracking tooltips code, but failed to achieve the objective. Kindly help.
Regars
Ashwin
|
|
|
|
|
What was the problem with the MSDN code?
Medication for us all
You think you know me, well you're wrong
|
|
|
|
|
Hello Thanks for the Reply,
Have you tried the code. If so please paste your function here, I would be very much greatful to you. As far as my try goes I do get a tracking rectangle follwing my mouse but it keeps blinking all the time I move the mouse and without the text I pasted in the code.
bool g_bIsVisible;
HWND g_hwndTT;
void CTestDlg::TooltipFunc()
{
INITCOMMONCONTROLSEX icex;
HWND hwndTT;
TOOLINFO ti;
// Load the tooltip class from the DLL.
icex.dwSize = sizeof(icex);
icex.dwICC = ICC_BAR_CLASSES;
if(!InitCommonControlsEx(&icex))
return NULL;
RECT rect;
GetClientRect (&rect);
// Create the tooltip control.
hwndTT = CreateWindow(TOOLTIPS_CLASS, TEXT(""),
WS_POPUP,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, (HMENU)NULL, AfxGetApp()->m_hInstance,
NULL);
// Prepare TOOLINFO structure for use as tracking tooltip.
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE;
ti.hwnd = m_hWnd;
ti.uId = (UINT)m_hWnd;
ti.hinst = AfxGetApp()->m_hInstance;
ti.lpszText = "Hello World";
ti.rect.left = ti.rect.top = ti.rect.bottom = ti.rect.right = 0;
// Add the tool to the control, displaying an error if needed.
if(!::SendMessage(hwndTT,TTM_ADDTOOL,0,(LPARAM)&ti)){
MessageBox("Couldn't create the tooltip control.",
"Error",MB_OK);
return NULL;
}
// Activate (display) the tracking tooltip. Then, set a global
// flag value to indicate that the tooltip is active, so other
// functions can check to see if it's visible.
::SendMessage(hwndTT,TTM_TRACKACTIVATE,(WPARAM)TRUE,(LPARAM)&ti);
g_bIsVisible = TRUE;
g_hwndTT = hwndTT;
}
void CTestDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(g_bIsVisible){
#define X_OFFSET 15
#define Y_OFFSET X_OFFSET
POINT m_point;
::GetCursorPos(&m_point);
::SendMessage(g_hwndTT,
TTM_TRACKPOSITION,
0,
(LPARAM)MAKELPARAM(m_point.x + X_OFFSET,
m_point.y + Y_OFFSET));
}
CDialog::OnMouseMove(nFlags, point);
}
BOOL CTestDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: Add your specialized code here and/or call the base class
LPNMTTDISPINFO lpnmtdi = (LPNMTTDISPINFO) lParam;
strcpy (lpnmtdi->szText, "Hello World");
return CDialog::OnNotify(wParam, lParam, pResult);
}
Regards
Ashwin
|
|
|
|
|
I am using following Code to Copy to Clip board.
This code is written under a button Copy ,
As i click on it first time it Works fine , and i can paste it in MS word.
As I clik 2nd time on Copy Botton . the Application Crashes down.
It crashes on statment pData->SetClipboard();
void CopyButton()
{
// Get DC
CDC* dcRef = GetDC();
tagSTGMEDIUM * data;
data = new tagSTGMEDIUM;
CMetaFileDC * dcMeta;
dcMeta = new CMetaFileDC();
if(!dcMeta)
{
AfxMessageBox("Unable to Load data on Clipboard");
return;
}
COleDataSource* pData = new COleDataSource;
//replace "ImageName" with a description of this image
dcMeta->CreateEnhanced(dcRef, NULL, NULL,"Cca-Graph" );
dcMeta->SetMapMode(MM_TEXT);
dcMeta->SetAttribDC(dcRef->m_hAttribDC);
//actually draw to the device context
CRect rcWnd;
GetClientRect(&rcWnd);
//draw meta file :: do what ever you want to do: bitmaps, lines, text...
DrawChart(dcMeta, rcWnd, false);
//done drawing
data->tymed = TYMED_ENHMF;
data->hEnhMetaFile = dcMeta->CloseEnhanced();
pData->CacheData( CF_ENHMETAFILE, data );
// Crashes
pData->SetClipboard();
// Release the meta file attributes
dcMeta->ReleaseAttribDC();
delete dcMeta;
delete data;
}
Regards.
|
|
|
|
|
I bet it's because you delete data. Once you call SetClipboard, data is no longer yours and windows handles it. When you call SetClipboard again, it's trying to delete the old pointer twice (because you already deleted it) which is bad.
|
|
|
|
|
HI
If i not Delete data , it also occured , i am very much confused why it is happening.
I am using Windows XP.
thanx
Regards.
|
|
|
|
|
What happens exactly? Are you ASSERTing or getting memory could not be read or what?
|
|
|
|
|