|
Hello, I'm using a CEdit in a CDialogBar to display and maybe editing some text files. When I read the file and put the contents in the CEdit it does not interptrets correctly the CR-LF pair and shows that weird square-characters on the control. No new line at all at the CEdit Control.
The CEdit has multiline and want_return flags.
Is there any way to load simple txt files in without having to manually convert CR_LF to other character?
PD: the text files are displayed correctly in notepad, VSstudio, etc etc.
regards
|
|
|
|
|
asmatic wrote:
Is there any way to load simple txt files in without having to manually convert CR_LF to other character?
I'm pretty sure you have use \r\n...or just \r...play with it a bit you'll figure it out.
How do I print my voice mail?
|
|
|
|
|
CString fileName="./Test.xls"
_WorkBook book
.....
_variant-t fName(fileName);
book.SaveAs(fName,covOptional,covOptional,covOptional,covOptional,covOptional,0,covOptional,covOptional,covOptional,covOptional);
Whatever I do I cannot save this in the current directory . it is always saved in th "My Documents" folder . Please help
|
|
|
|
|
Have you tried using CString fileName=".\\Test.xls" ? Office doesn't respond favourably to Unix-style paths...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi, all!
Working on one of the projects I need to distinguish menu resources in local and network version. That was done through the Insert Copy... with condition set. But after that, every time I change something in resources or in Resource.h I get menu item with conditions quoted!
If it has before conditioning IDR_MAINFRAME, now it is "IDR_MAINFRAME" <- quoted... And I cant load that resource at run-time.
Does anybody know, is this behaviour is by design? Or what is that?
GREAT Thanks!
p.s. If it was for ex. IDR_TestIssue it will come as "IDR_TESTISSUE" - quoted and uppercased
|
|
|
|
|
Hi guys, what I have to doto make my SDI app non-resizable.
Best Regards.
Doc
|
|
|
|
|
Try to set min/max sizes and handle OnSize() of course.
|
|
|
|
|
Sorry my ignorance
But where I have to control OnSize()
CMyApp ?
CMyAppView ?
and where inside the right class?
Doc
|
|
|
|
|
Look here and go to "4.18: How do I restrict my window so it can't be resized larger or smaller than a certain size?"
Set pmmi->ptMinTrackSize.x equal to pmmi->ptMaxTrackSize.x,
pmmi->ptMinTrackSize.y equal to pmmi->ptMaxTrackSize.y (in CMyAppView). I think it will work.
|
|
|
|
|
You can try WM_GETMINMAXINFO.
Omar - VC++ Programmer
|
|
|
|
|
I know you're trying to be helpful but did you know you answered a question that was posted in 2004?
|
|
|
|
|
Sorry.
Omar - VC++ Programmer
|
|
|
|
|
I have an 'image' field that I would like to use to store files. I open the file using a CFile object then read the bytes into a BYTE array. But how do I use that to insert the contents of the byte array. My insert statement would look something like this:
str.Format("INSERT INTO tblFile (name,data) VALUES ('%s',??)","file.txt",??);
the question marks indicate where I don't know what to put. any help would be appreciated. Thanks in advance.
[insert witty comment here]
bdiamond ![Sleepy | :zzz:](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_snore.gif)
|
|
|
|
|
One way to do it is to specify the binary data in hex. For instance...
INSERT INTO tblSomething (BinaryColumn) VALUES (0xFF) However, I'd suggest using ADO properties and methods for this to avoid messing with the hex conversions, etc.
Search online for SQL Server and BLOBs and you're bound to find an example or two.
Jeremy Falcon
|
|
|
|
|
You could possibly use a Stored Procedure ang get this to reade the fil directly and then insert it into the database.
store your internet favourites online - www.my-faves.co.uk
|
|
|
|
|
Hello
I use MFC in a DLL. When linking, i get a messinge telling that _DllMain@12 symbol is already defined in a library
nafxcwd.lib and there is a conflict with the symbol defined in my program. Isn't it possible to use MFC in a DLL ? If
possible, how to do it ?
Thank you
|
|
|
|
|
|
Thank you, but I hava already tried this. This is not exactly my problem. In your example, there is a conflict between two libraries, so you have to include them in the right order. For instance ' mfcs42d.lib(dllmodul.obj): error LNK2005: _DllMain@12 already defined in
msvcrtd.lib(dllmain.obj)'
In my problem, the symbol is already defined in prog.obj (which must be the object code associated with my code prog.cpp) :
'msvcrtd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in prog.obj'
As I'm developping a DLL, I think there is a conflict between my DllMain and the one from the library
|
|
|
|
|
I have (perhaps) solved the problem by including my DllMain in a namespace. The DLL is compiled and linked, but I can't use my dialog :
CDlgParamSynchro* dlg = new CDlgParamSynchro
(CWnd::FromHandle(this->h_fen)) ;
dlg->DoModal() ;
(this->h_fen is a HWND on a window)
The dialog is initialized then display but frozen
|
|
|
|
|
I've solved my problem by including my DllMain in a namespace
|
|
|
|
|
well Im working on clock program...
BOOL CMyDigClockDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
SYSTEMTIME CurTime;
CString Time, tmp;
GetLocalTime(&CurTime);
bool cPM = false;
if(CurTime.wHour >12) {
CurTime.wHour -= 12;
cPM = true; }
Time.Format("%u:", CurTime.wHour);
if(CurTime.wMinute <= 9)
{
tmp.Format("0%u:", CurTime.wMinute);
Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength()));
}
else {
tmp.Format("%u:",CurTime.wMinute);
Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength()));
}
if(CurTime.wSecond <= 9)
{
tmp.Empty();
tmp.Format("0%u", CurTime.wSecond);
Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength()));
}
else {
tmp.Empty();
tmp.Format("%u",CurTime.wSecond);
Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength()));
}
if(cPM == true)
{
Time.Insert(Time.GetLength()," PM");
}
else {
Time.Insert(Time.GetLength()," AM");
}
m_clock.SetWindowText(Time);
SetTimer(55,1000,NULL);
char sIniFile[MAX_PATH];
GetModuleFileName( NULL, sIniFile, MAX_PATH );
strcpy( strrchr( sIniFile, '\\' ) + 1, "reminderclock.ini" );
char getname[MAX_PATH];
char gethour[MAX_PATH];
char getminutes[MAX_PATH];
char getname2[MAX_PATH];
char gethour2[MAX_PATH];
char getminutes2[MAX_PATH];
char getname3[MAX_PATH];
char gethour3[MAX_PATH];
char getminutes3[MAX_PATH];
char getname4[MAX_PATH];
char gethour4[MAX_PATH];
char getminutes4[MAX_PATH];
char getname5[MAX_PATH];
char gethour5[MAX_PATH];
char getminutes5[MAX_PATH];
char getname6[MAX_PATH];
char gethour6[MAX_PATH];
char getminutes6[MAX_PATH];
GetPrivateProfileString("BOX1", "Title", "", getname, sizeof(getname), sIniFile);
GetPrivateProfileString("BOX1", "Hour", "", gethour, sizeof(gethour), sIniFile);
GetPrivateProfileString("BOX1", "Minutes", "", getminutes, sizeof(getminutes), sIniFile);
GetPrivateProfileString("BOX2", "Title", "", getname2, sizeof(getname2), sIniFile);
GetPrivateProfileString("BOX2", "Hour", "", gethour2, sizeof(gethour2), sIniFile);
GetPrivateProfileString("BOX2", "Minutes", "", getminutes2, sizeof(getminutes2), sIniFile);
GetPrivateProfileString("BOX3", "Title", "", getname3, sizeof(getname3), sIniFile);
GetPrivateProfileString("BOX3", "Hour", "", gethour3, sizeof(gethour3), sIniFile);
GetPrivateProfileString("BOX3", "Minutes", "", getminutes3, sizeof(getminutes3), sIniFile);
GetPrivateProfileString("BOX4", "Title", "", getname4, sizeof(getname4), sIniFile);
GetPrivateProfileString("BOX4", "Hour", "", gethour4, sizeof(gethour4), sIniFile);
GetPrivateProfileString("BOX4", "Minutes", "", getminutes4, sizeof(getminutes4), sIniFile);
GetPrivateProfileString("BOX5", "Title", "", getname5, sizeof(getname5), sIniFile);
GetPrivateProfileString("BOX5", "Hour5", "", gethour5, sizeof(gethour5), sIniFile);
GetPrivateProfileString("BOX5", "Minutes5", "", getminutes5, sizeof(getminutes5), sIniFile);
GetPrivateProfileString("BOX6", "Title", "", getname6, sizeof(getname6), sIniFile);
GetPrivateProfileString("BOX6", "Hour6", "", gethour6, sizeof(gethour6), sIniFile);
GetPrivateProfileString("BOX6", "Minutes6", "", getminutes6, sizeof(getminutes6), sIniFile);
m_name = _T(getname);
m_hour = gethour; ----- PROBLEM HERE -----
// m_minutes = getminutes;
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
ERROR HERE:
--------------------Configuration: MyDigClock - Win32 Debug--------------------
Compiling...
MyDigClockDlg.cpp
C:\-= My Stuff =-\-= programs =-\-= MY CLOCKS =-\MyDigClockTest\MyDigClockDlg.cpp(268) : error C2440: '=' : cannot convert from 'char [260]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Error executing cl.exe.
MyDigClock.exe - 1 error(s), 0 warning(s)
look at the bottom of the code.
m_hour = gethour; is problem.
how could get numbers from ini to load in the edit boxes properly ?
|
|
|
|
|
The problem is that gethour is a string whereas m_hour is (presumably) an int.
Instead of using GetPrivateProfileString(), you could use GetPrivateProfileInt().
store your internet favourites online - www.my-faves.co.uk
|
|
|
|
|
I'm seeing several calls to GetBuffer() without corresponding calls to ReleaseBuffer() . To that end, GetBuffer() is not even necessary in the context in which you are using it. That's what CString 's LPCTSTR operator is for.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I have two edit controls A and B(IDC_A,IDC_B). Their member variables are type "double". If I change A, B has automatically change (by the realationship m_myB = 2*m_myA). I have the following code (received from a member of this community)
..
void CYourDialog::OnChangeIDC_A()
{ CString str;
CWnd *pCtrl = GetDlgItem(IDC_A);
if(pCtrl)
{ pCtrl->GetWindowText(str); GetDlgItem(IDC_B)->SetWindowText(str);
}
}
In general, the code works well. That means, that the value of edit control A automatically appear in B.
But : My problem (due to I am new in C++): Where is my function (m_myB = 2*m_myA)to be placed within the code above? The program gets problems because str is a string and the variables are double. Maybe I have to use other function instead of GetWindowText ?
Thanks a lot.
|
|
|
|
|
Use this instead (if you are using MFC):
void CYourDialog::OnChangeIDC_A()
{
UpdateData(TRUE); // Save data from edit box into the variables
m_myB = 2*mmyA;
UpdateData(FALSE); // Print data from the variables into the edit boxes
}
Hope this helps
|
|
|
|
|