|
I'm putting together a framework for Win32 consoles (to make it easier to change font, background color, change title, and to teach myself Win32) and I was curious if it would be possible to define my own escape sequences using C++ (like \n, \t, etc), to change the font, clear the screen, or do custom formatting. I already know how to change the font under Win32 but it would be convieniant if I didn't have to clutter up the code with function calls. Any ideas?
|
|
|
|
|
CoffeeAddict19 wrote: I already know how to change the font under Win32 but it would be convieniant if I didn't have to clutter up the code with function calls. Any ideas?
How would you prefer to do it?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
There would be maybe 3 classes defined and 4 involved. 2 classes (one for each buffer, and duplicates of each other) do the actual low level Win32 function calls for their respective buffers. They would use this function to change the font, change the buffer size, the cursor position, and the window size:
void SetBufferInfo(int NewXCord, int NewYCord, PrintColorType ForeColor, PrintColorType BackColor, SetBufferType BufferAction); //sets buffer info
Another class which contains both of those buffer classes as private members acts as an interface between the client and the other two low-level buffer classes. It uses a set of of functions to change the title, change the font color, clear the screen, switch the active buffer so I can do double buffering, etc.
Another class (the client in this case) would set it up so that certain escape sequences, when read from a stream, would invoke the functions in the interface class described above.
-- modified at 14:18 Friday 9th June, 2006
|
|
|
|
|
CoffeeAddict19 wrote: Another class (the client in this case) would set it up so that certain escape sequences, when read from a stream, would invoke the functions in the interface class described above.
If you define a reader to look at each charater (or set of characters) before displaying them, you can do anything you want. What you are basically doing is writing your own markup language in that case.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
CoffeeAddict19 wrote: Another class (the client in this case) would set it up so that certain escape sequences, when read from a stream, would invoke the functions in the interface class described above.
So what's the problem? When those special characters are encountered, call the appropriate functions.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Would using an if statement to check each character encountered (to see if it's a tag) slow the program down signifigantly?
|
|
|
|
|
Not based on what you've told us so far.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Within the language, no, you cannot define your own. The escape sequences are standard.
However, if you want to write your own markup (or use an XML data file), you can wrap the calls to do such formatting into a single function to make it easy for you to write your code.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I've found, reviewed and implemented several TabCtrl examples...but I've run into a snag I hope you experts can help me with!
I need to dynamically update the controls in the child dialogs (from common controls from the parent TabDlg) but since the called dialogs are initialized during creation they do not update!
How do I 'refresh' the dialogs as global's (in the TabDlg) change which will modify objects in the called dialogs (MyDlg1, MyDlg2...)?
Effectively my application will periodically receive updated information which will modify the states of these tabbed child dialogs such that they must be updated periodically as well. How do I create a function to 'refresh' the dialogs? E.g. A button control on a dialog is visible by default but when a user changes a setting (with a ctrl on the tabDlg) this button should be invisible (or disabled)). Or alternative e.g., a 'default' buttonCtrl on the TabDlg should be able to set all controls on all dialogs back to a known state. Right now the child dialogs get set on initialization (creation) and I while the controls on these dialogs can perform actions, controls on the parent do not effect change on these dialogs.
Basically, parent Dialog control must effect changes to the child dialogs and the parent Dialog (TabDlg) must be aware of selections/settings of the child Dialog controls.
Thanks MUCH for any help/insight you can provide!
...an embeddedDude swinging into the VC++ world!
|
|
|
|
|
Hi there!
I'm developing a windows service (or should I say trying...), that needs to access data in some database.
I have already a library (in a separate dll, with static linking) that uses ADO via the COM Interface, to access data.
Also, I’ve started by looking at some samples here at CodeProject, specially the article by PJ Naughter and he’s library CNTService framework.
Now the problem: the service is installed correctly, but it will always fail to start, and it reports the error: 1053 – “The service did not respond to the start or control request in a timely fashion.”
Can anyone tell me what the problem might be?
Tanks in advance for your time.
ALMC
|
|
|
|
|
Hello People
I need help with a linker problem that I can’t solve. I am working on a project that is comprised of 3 static libraries and the main application. Workspace is comprised of 4 projects, 3 corresponding to the libraries and one project for the main application. When I compile and run in Debug Mode everything is fine. When I try to compile for Release mode, I get linker errors as follows:
CVGw32Doc.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CVGw32Doc::OnSaveDocument(char const *)" (?OnSaveDocument@CVGw32Doc@@UAEHPBD@Z)
CVGw32Doc.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CVGw32Doc::OnOpenDocument(char const *)" (?OnOpenDocument@CVGw32Doc@@UAEHPBD@Z)
CVGw32Doc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CVGw32Doc::MyEmptyDatabase(void)" (?MyEmptyDatabase@CVGw32Doc@@QAE_NXZ)
All the errors are related to the document object in the main application. The first two errors are related to the virtual functions that have been overwritten and the last function is a public member of my own code. I have read all the online help of MSDN for this error and nothing at all seems to make sense, especially as two of the functions are part of standard library.
I have no idea why the linker can not find the code from the libraries supplied as part of the compiler. The same error persists in VC++ version 6 and the 2005 edition. I even made an application and added all files to a single application instead of using the libraries and the same thing still happens. All classes are there, nothing is missing. I have no idea what is happening.
Any help is appreciated.
Fariborz Nouri
|
|
|
|
|
Some things to check for:
1) See if a Rebuild All (or a Clean-then-Build) will fix it. Sometimes incremental builds have issues that show up when linking.
2) Check the version of the libraries each of your libraries is using. That is, make sure that if you are using MFC (which it appears you are), all apps and libraries using MFC have the "Using MFC" selection checked in your Project Settings. Also, check the code generation to make sure they are all using the same type of threading library (linking a library that uses a single-threaded library to an app that uses the multi-threaded library gives weird linking errors).
3) Finally, if neither of those worked, try comparing each and every setting between your Debug and Release build configurations. Try copying all the debug settings over to your release build and slowly undoing them 1-by-1 to find which setting is causing the differences.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi,
I'm migrating a project from VS 2003 to VS 2005. As always, exporting templates (instantiations of them) is a hard work. The problem is that I'm exporting an std::iterator implementation and, to avoid warnings, I have to export also its base classes, for example: _Iterator_base. The problem is that in release, this is a struct, and in debug this is a class!!! Do you know if there's a workaround other than doing another #ifdef...??
I'll really appreciate any clue!
Thanks in advance,
Federico
|
|
|
|
|
I have a dialog box that I would like to increse a variable everytime a button is pushed, but instead once the button is pushed the variable is set to 2376868 everytime. Using message boxes to debug a little I determined that the variable seems to randomly increse in the WM_COMMAND part of my message loop. My dialog procedure looks something like:
BOOL CALLBACK dlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
int number;
switch (msg)
{
case WM_INITDIALOG:
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_REGISTER:
number += 1;
EndDialog(hwnd, 0);
break;
}
break;
case WM_CLOSE:
EndDialog(hwnd, 0);
break;
default:
return FALSE;
}
return TRUE;
}
Any thoughts on how to fix this? Thanks
-Matt
|
|
|
|
|
number has not been initialized.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
case WM_INITDIALOG:
number isn't initialized but the value is stored from an INI file within WM_INITDIALOG
|
|
|
|
|
Then you must change it from auto to static .
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You number variable is a non-static local one (in addition, it is not initialized), therefore its value will be lost after you exit the dialog procedure.
If you need it only within the function, declare it as static, and initialize:
BOOL CALLBACK dlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static int number = 0;
...
}
If you need it outside, then move it on file level.
|
|
|
|
|
making it a static variable fixed the problem...thanks a lot!
|
|
|
|
|
how the datetime picker store date
as edit box can store SetDlgItemText()
Please mail me
|
|
|
|
|
yogendra kaushik wrote: how the datetime picker store date
Use CDateTimeCtrl::SetTime() , or if you are not using MFC, send the control a DTM_SETSYSTEMTIME message.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hi,
i develop one application in VC++-MFC 6.0 ,
this application is responsible for inserting image into the database (oracle)-ODBC.
but when i try to insert a image file , it through a error like
"Data type conversion error."
////////////////////////////////////////////////////////////////////////
CDaoDatabse db;
CDaoRecordset recset(&db);
void CDBODBC::InsertintoDB();
{
CByteArray BlobFile;
BlobFile.RemoveAll(); // I clear the Array
CFile aFile("image.jpg",CFile::modeRead);
BlobFile.SetSize(aFile.GetLength());
aFile.Read(BlobFile.GetData(),aFile.GetLength());
aFile.Close();
COleVariant aVar(BlobFile);
CString Sql = "SELECT * FROM sample3";
db.Open("abc",FALSE,FALSE,"ODBC;UID=abcWD=abc;DSN=abc;");
recset.Open(AFX_DAO_USE_DEFAULT_TYPE,Sql,dbAppendOnly);
// bool b=recset.CanUpdate();
recset.AddNew();
recset.SetFieldValue("[num]","6"); //varchar field
recset.SetFieldValue("[photo]",aVar); //BLOB field -image field
recset.Update();
recset.Close();
db.Close();
}
/////////////////////////////////////
it works for Access database ..
but i got error in oracle...
"Data type conversion error."
Try again and again,
At last you will say
I don't know the meaning for impossible.,.
|
|
|
|
|
See if this helps.
maharaja pandian wrote:
CDaoRecordset recset(&db);
In addition, if you would derive a class from CDaoRecordset , the RFX_Binary() code would handle the details for you.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
tnx for ur reply,
but COleVariant is used to store the "OLE object" datatype in .MDB database.
when i use oracle DB , the corresponding BLOB datatype is not get matched with COleVariant class in VC++.
I got the error like " Data type conversion error"
can u please send the details to store the oracle BLOB value
throuh VC++.
Try again and again,
At last you will say
I don't know the meaning for impossible.,.
|
|
|
|
|
|