|
Hi,
you've got to do it the hard way, dont use CString use a char buffer to access the edit box.
But char buffers are a very hard way to deal with strings so it would be better to use the std::string class. (this requires #include <string>
You will need to get the text from the control then append your extra data and next send the text back to the control. To simplefy this I wrote 2 wrapper funtions SetText and GetText . This gives the following code:
std::string CMyDlg::GetText(UINT uiControl)
{
CWnd* pWnd = GetDlgItem(uiControl);
if(pWnd)
{
std::string sTemp;
int iLen = pWnd->GetWindowTextLength();
char* pBuffer = new char[iLen+1];
pWnd->GetWindowText(pBuffer, iLen+1);
sTemp.assign(pBuffer, iLen);
delete pBuffer;
return sTemp;
}
return "";
}
void CMyDlg::SetText(UINT uiControl, std::string sText)
{
CWnd* pWnd = GetDlgItem(uiControl);
if(pWnd)
{
pWnd->SetWindowText(sText.data());
}
}
void CMyDlg::AddText(std::string sAdd)
{
std::string sText = GetText(IDC_MY_EDIT);
sText += sAdd;
SetText(IDC_MY_EDIT, sText);
}
This should work ...
codito ergo sum
|
|
|
|
|
Thank you for your reply. but I figured out a easy way, CEdit class member function SetLimitText(xxxx); set to -1 is maximum. It works fine. by default, it stops when getting 30000 bytes.
Good Luck
|
|
|
|
|
Hi Experts,
I am trying to move a DLL build in C++ from my desktop to Pocket PC
applications.
I build a new project in VS2005 C++, for "Smart Device", "MFC Smart Device
DLL", choose Pocket PC. And I copied all the source files (.h and .c .cpp) to
this new project. I have the error when i tried to compile it:
Error 1 fatal error C1083: Cannot open include file: 'mbctype.h': No such
file or directory C:\Program Files\Microsoft Visual Studio
8\VC\ce\atlmfc\include\afxv_w32.h 227
The DLL built for desktop application works fine (using VS2003). I checked
the Project properties, and found that in VS2003, i set "Use Managed
Extensions" to "No" under "configuration properties", but there is no such
setting options in VS2005.
Could you please tell me how i can solve this problem?
Thanks a lot!
Vicvic
Thanks!
vic
|
|
|
|
|
Use Unicode Character Set
HOHOHOHOO
|
|
|
|
|
Binary presentation of data
Hi all;
We all know that data stored in PC in binary code 1 or 0 ;
I need to know how we can to get binary code of file or
any thing
Thanks;
AMR-CIS
|
|
|
|
|
please be more precise... you need to get what exactly, and what for ?
is it for a display purpose ?
as you said : "We all know that data stored in PC in binary code 1 or 0" so why would you need to convert into binary, as whatever you manipulate so is already in that way in memory ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
well, to read binary from a file, use fopen to open a file, and fread to read unformated data from the file.
for the "any thing", you will need to be more precise in your question.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Can someone point me in the right direction for doing my first ActiveX control in Visual Studio .Net (MFC C++).
I have a MFC application that uses the USB joystick port, but would now like to convert it to an ActiveX.
Many thanks,
|
|
|
|
|
Hi all,
Iam working with a ListControl whose parent is a dialog. In the cell (1,1),I want to place a tree control which on doubleclicking should open up(ie: the width & height of this tree control exceeds the dialog boundary).
Will move the treecontrol & place it over the cell(1,1) position.
Now If I fix & width & I height of my treecontrol,I want the same size to be displayed,even if the parent dialog is smaller.
ie: If the childControl size is bigger than,the parentcontrol size ,it should overflow the parentcontrol boundary.(like if we click on a comboBox).
How can I achive this behaviour.
Any ideas
Thanks..
|
|
|
|
|
The dropdown listbox from a combobox is actually created as a top level window, a child of the desktop, and it is moved into place and shown when needed. You could do the same with your tree control.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
>>The dropdown listbox from a combobox is >>actually created as a top level window, >>a child of the desktop, and it is moved >>into place and shown when needed.
How could I do this?.would you be able to explain it by a piece of code...
|
|
|
|
|
Hi,
I did as follows in that order & I get the child control to exceed the parent window.
childControl.SetParent(GetDesktopWindow());
childControl.ShowWindow(true);
childControl.BringWindowToTop();
childControl.SetFocus();
childControl.MoveWindow(500,300,400,200);
But now the problem is ,I don't get the childControl as an activeWindow(Can't select,edit anything etc).
Thanks..
|
|
|
|
|
hi, I have a thread function that starts when user press OnRun button. I want that when user click on OnStop button I want the code the behind Stop button kill the thread. How can I do that..
The code is here
void CAppDlg::OnRun() <br />
{<br />
<br />
AfxBeginThread(ThreadFunction, this); <br />
}<br />
<br />
void CAppDlg::OnStop() <br />
{<br />
<br />
??????????????????<br />
}
|
|
|
|
|
just declare a boolean flag which you switch in your OnStop() function...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Try AfxEndThread(..,..)
void AFXAPI AfxEndThread(
UINT nExitCode,
BOOL bDelete = TRUE
);
This will end the current thread.
<marquee direction="up" height="30" scrolldelay="1" step="1" scrollamount="1" hspace="0" vspace="0">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
MuratMetu wrote: hi, I have a thread function that starts when user press OnRun button. I want that when user click on OnStop button I want the code the behind Stop button kill the thread. How can I do that..
In Continuation With Tox....
you also try your hand on TerminateThread api.. but use it in speacial circumstances only.... i am listing the name of api for your information only
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi all
I've been teaching C++ for about 10 years (unmanaged using Borland Compilers), and for the first time this year I am teaching managed C++ using MS Visual Studio .NET. The first part of the course concentrates on procedural programming in a console environment, and one of the topics is writing / reading to text files (which is OK), and printing data to a printer (local LPT1 printer). In unmanaged code, I would write is as follows :
#include <fstream.h>
void main(void)
{
char data[80];
ifstream infile;
ofstream printer;
infile.open("TEST.TXT", ios::in);
printer.open("PRN");
while (infile)
{
infile.getline(data,80);
if (infile)
{
printer << data << "\n";
}
}
};
However, I cant find a simple way to set up a stream to the local printer in a console based environment using managed code. The file handling part is fine, and would look as follows :
// Filein1.cpp
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::IO;
int _tmain()
{
String *record;
StreamReader * fileIn = File::OpenText(S"Test.txt");
// Need to set up stream to printer here
while ((record = fileIn->ReadLine()) != 0)
{
Console::WriteLine(S"{0}",record); // need to replace with output to printer stream
}
Console::ReadLine();
fileIn->Close();
return 0;
}
Can anyone help me fill in the gaps ?
Many thanks
Simon Cornish
|
|
|
|
|
|
I'm creating a procedure to add bitmap image on status bar.
The problem is i don't know how to do it. If you know some links,
articles or know how to do it, please reply to my post. Your help
would be greatly appreciated. Thanks!
|
|
|
|
|
Does anyone know how to use this!
I need to make the background of my AVI transparent. I'm capturing the OnCtlColorStatic message, but what next?
I search the docs and the web but have found conflicting examples. Should I be returning a BOOL from this message (to say I've handled it) or a HBRUSH? or something completely different!
I'm lost - Can anyone shed any light on this (a snippet of code would be useful!)
Kevin.
|
|
|
|
|
Have you set the ACS_TRANSPARENT style when you created the control? That should be all you have to do.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Hello
How can one make a tooltip alpha blended? I've grabbed the code from MSDN, and added a WS_EX_LAYERED style to the tooltip and call to SetLayeredWindowAttributes(), which seems to be enough. But it does not work. Here's code:
void CreateMyTooltip (HWND hwnd)
{
// struct specifying control classes to register
INITCOMMONCONTROLSEX iccex;
HWND hwndTT; // handle to the ToolTip control
// struct specifying info about tool in ToolTip control
LPTOOLINFO ti;
unsigned int uid = 0; // for ti initialization
char strTT[30] = "This is your ToolTip string.";
LPTSTR lptstr = strTT;
RECT rect; // for client area coordinates
/* INITIALIZE COMMON CONTROLS */
iccex.dwICC = ICC_BAR_CLASSES;
iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCommonControlsEx(&iccex);
/* CREATE A TOOLTIP WINDOW */
hwndTT = CreateWindowEx(WS_EX_TOPMOST,
TOOLTIPS_CLASS,
NULL,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP | WS_EX_LAYERED| WS_EX_TOOLWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
300,
200,
hwnd,
NULL,
NULL,
NULL
);
SetLayeredWindowAttributes(hwndTT, 0, (255 * 70)/100, LWA_ALPHA);
gOldTooltipWndProc = (FARPROC)SetWindowLong(hwndTT,
GWL_WNDPROC,
(DWORD)TooltipWndProc);
/*SetWindowPos(hwndTT,
HWND_TOPMOST,
0,
0,
0,
0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);*/
/* GET COORDINATES OF THE MAIN CLIENT AREA */
GetClientRect (hwnd, &rect);
/* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */
ti = new TOOLINFO;
ti->cbSize = sizeof(TOOLINFO);
ti->uFlags = TTF_ABSOLUTE | TTF_TRACK;
ti->hwnd = hwnd;
ti->hinst = NULL;
ti->uId = uid;
ti->lpszText = LPSTR_TEXTCALLBACK;//lptstr;
// ToolTip control will cover the whole window
ti->rect.left = 0;
ti->rect.top = 0;
ti->rect.right = 0;
ti->rect.bottom = 0;
/* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */
SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) ti);
SendMessage(hwndTT, TTM_TRACKACTIVATE, (WPARAM)TRUE, (LPARAM)(LPTOOLINFO)ti);
gHwnd = hwndTT;
gpTi = ti;
}
What am i doing wrong? Thanks for help
|
|
|
|
|
Hi All,
I am in a bottleneck and need your help to come out of it. I have a Shell DLL which will load from a USB CDROM media. When the shell is loaded and my computer is open the tray Icon on the system tray is not allowing me to stop the device. To overcome this I have to logoff logon each time. I tried the normal ways of Unloading the shell DLL (By using DllCanUnloadNow()) still no use.
Thanks for your help in advance,
Raja.
|
|
|
|
|
i am a final year student from uitm.right now i am doing my final year project. i got a problem on how to develop a chat appliCation by using c++ language. my thesis title is ipv6 multicast chat application. i have to create a chat application for this. it doesn't matter whether it is a simple one.but i do not have enough skills in programming language. i have try to do it but not success. so i really really hope that if someone here who are really capable of doing chat application using c++ programming to help me.
so someone please HELP me.
-- modified at 7:48 Thursday 24th November, 2005
|
|
|
|
|
Hello,
I'm trying to modify a black&white bmp file by replacing certain areas with the data obtained from other bitmaps. I have no problem in doing this with the gdi+ functions. My problems have arrived when I have tried to insert strings in some places in the bmp file. I just don´t know how to do it. Can anybody give me the clue?
Any help will be really appreciated,
Itziar
|
|
|
|