|
converting string to interger: value strtol(), strtoul().
converting interger value to hex string: sprintf(pStr,"%X",nValue).
If you want to convert to hex string with leading 0's:
sprintf(pStr,"%8.8,X",nValue); // 00000000
Or
sprintf(pStr,"%*.*,X",8,8,nValue); // 00000000
I believe those should work for ASCII formated string.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi all,
I am writing a program that continuously stores data from an external memory.
while(isConnected)
{
// Do stuff over here
}// end while
However, when it runs, it takes all the memory (program is not responded).
I have another button (Stop) to call method to set isConnected to False in order to get out of the loop. However, I didn't even have a chance to hit that button because the program is freezed.
Any suggestions? Thanks.
|
|
|
|
|
|
Use a worker thread. If you don;t thread the application, then the reason you're locking the program up is because the Message Loop never has the chance to run, and therefore the button press is never noticed. Use a thread for the user interface, and one to do the loop.
|
|
|
|
|
An alternative is to pump the message queue every n iterations of the loop. There is no need to create a worker thread.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hello,
I'm writing to ask some explanations on the excellent article "Using Custom Controls in a Dialog Bar" by Douglas R. Keesler, see http://www.codeproject.com/useritems/DerivedDlgBar.asp. Maybe that I did not understand everything, I'm french and my english is not so good.
So my matter is about how to create a menu in a CDialogBar :
I have made a little MDI which has got a CDialogBar with VC++6.0 .
In this class, I want to put a Menu.
So I made that you said :
- create a CDialogBar : IDD_DLGBAR_TEST ,
- create a Menu in my ressource : IDD_DLGBAR_TEST ,
- create the class MyDlgBar (import files MyDlgBar, remove file.clw and clic on ctrl+w to wizard VC6.0 as he said)
- select to this ressource the classe MyDlgBar
- put in the class CMainFrame the instance : CMyDlgBar m_dlgBarTest
- put the creation of this box in the create function of the CMainFrame with :
m_dlgBarTest.Create(this, IDD_DLGBAR_TEST, <br />
CBRS_RIGHT | CBRS_GRIPPER |CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE,<br />
IDD_VIEW_MENU_DLGBAR)
- I put, in the message map of my CMainFrame, the 2 lines :
ON_COMMAND_EX(IDD_VIEW_MENU_DLGBAR, OnBarCheck)<br />
ON_UPDATE_COMMAND_UI(IDD_VIEW_MENU_DLGBAR, OnUpdateControlBarMenu)
- then I compile and I built my application.
When I execute this application, I have got :
- the main frame
- the floating dialog box (CDialogBar)
But I haven't got the menu of this floating box !
I search in the source of the demo project but I don't see the menu that we could see in the article.
Perhaps the autor forgot to write something to realize a menu in a CDialogBar?
Or perhaps I don't understand all ...
Could you explain to me how to realize it ?
Thanks very much to help me !
Alice
|
|
|
|
|
Maybe this will be disappointment for you but child window cannot have menu. Since dialog bar is a child window (either main frame or floating frame) it will not show menu.
JohnCz
|
|
|
|
|
How does one implement undo functionality in a Vc++ environment . Always is a definete wish list thing but dont have a clue as to how to implement it .
Engineering is the effort !
|
|
|
|
|
I would start by typing "Undo" (sans quotes) in the search bar on the top of this page (directly under Bob) and read the articles that are listed.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
since "undo" is a vast and sometimes complex domain, I suggest that you examine the following :
Undoing an operatation depends on the way the operation was done initially.
for example, you do a "create something" operation/command, the undo operation/command might simply be a cut or a remove, or worse, an "uncreate something"; do after that, if you go furher, what is the undo of the undo ( redo ); is it do a "create something" again ? or a paste or something ?
in my opinion, a good undo/redo system depends on the way you handle the different commands ( or actions) in your application.
for example, in a DB, you create a new record, the command that creates the record should contain as much context as possible so that you can recreate the record without any user action.
if you look from the other side.
you remove a record and do an undo, what is the result command ? is it a "create record" or something like a "paste" ?
...
so there are a lot going on here...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Im having this wierd problem regarding outputing a file in the same path as the .exe, whenever i save the settings for my app it always save it to the desktop i have no idea why...its suppose to save it in the same path as the exe.. this is the first time ive had this kind of problem, this is almost the same code i always use and yet its not working the way it should be i dont know why..
heres the code
heres the defined values:
#define FILENAME_S "settings.ini"
#define STRINGi "Font=%s\nFont_Size=%d\nShow_Margin=%d\nShow_Toolbar=%d\nShow_Workspace=%d\nShow_Status=%d\nFile1=%s\nFile2=%s\nFile3=%s\nFile4=%s"
This is part of this FILESTUFF CLass
int FILESTUFF::saveIni( SETTINGS *st )
{
FILE *file;
if( ( file = fopen( FILENAME_S, "w+" ) ) == NULL )
return 0;
stripSpace( st->font, 1 );
stripSpace( st->file1, 1 );
stripSpace( st->file2, 1 );
stripSpace( st->file3, 1 );
stripSpace( st->file4, 1 );
fprintf( file, STRINGi , st->font, st->fontSize, st->showMargin, st->showToolbar, st->showWorkspace, st->showStatusBar, st->file1, st->file2, st->file3, st->file4 );
loadIni( &*st );
fclose( file );
return 1;
}
int FILESTUFF::loadIni( SETTINGS *st )
{
FILE *file;
if( ( file = fopen( FILENAME_S, "r+" ) ) == NULL )
return 0;
fscanf( file, STRINGi , st->font, &st->fontSize, &st->showMargin, &st->showToolbar, &st->showWorkspace, &st->showStatusBar, st->file1, st->file2, st->file3, st->file4 );
stripSpace( st->file1, 0 );
stripSpace( st->file2, 0 );
stripSpace( st->file3, 0 );
stripSpace( st->file4, 0 );
return 1;
fclose( file );
}
I have no idea
|
|
|
|
|
If you only specify the file name, not the entire path as you are doing, then the file will be opened in the current working directory which is not necessarily the same as app's installed directory. To ensure the file is saved in the directory you want it in always specify the full path.
You can use GetModuleFileName() to get the path to the exe.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Yeah i can use that function, but there must be an explanation why this is happening, and my current working directory isnt my desktop so it wont be that.. there must be some thing else i did wrong just dont know wht it is...
I have no idea
|
|
|
|
|
RealityGamma wrote:
...and my current working directory isnt my desktop...
How are you verifying this?
As has already been mentioned, if you do not specify an absolute path, a relative path is assumed.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I am trying to change an ISAPI Extension so it uses Thread Pooling.
I've downloaded the sample from Microsoft and able to get it running.
The problem I am encountering has to do with the AfxBeginThread
function and a Runtime Class. I don't know how to let the class know
how to pass any parameters through the UI thread.
The unconverted ISAPI Extension uses this call:
CClientSession* pWinThread =
(CClientSession*)AfxBeginThread(RUNTIME_CLASS(CClientSession));
Whereas the sample uses:
CWinThread* pWinThread =
AfxBeginThread((AFX_THREADPROC)ThreadProc, m_hIoPort);
Note the MS Example AfxBeginThread uses the ThreadProc overload, the
existing project however uses CClientSession, which inherits from
CWinThread.
How can I let the CClientSession thread know about m_hIoPort the I/O
Completion Port?
<signature>
It's good to live,
Josef Wainz
Software Developer
|
|
|
|
|
The AfxBeginThread function has a parameter called dwCreateFlags . Set the value of that parameter to CREATE_SUSPENDED , set any of the threads member variables to whatever you want then call CWinThread::ResumeThread to run the thread.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hi all,
can anyone tell me if it is possible to automate MS Access so that I can perform the following tasks from my C++ application:
Open Access
Create a new database
Add a table
Add columns to table
Add data to table
Close table
Close database
I've done similar things for Excel and PowerPoint but can't find any examples on how to do this for Access (I've got as far as getting Access to open, but that is it).
many thanks,
Andy
|
|
|
|
|
Using Automation, just add classes from the msacc9.olb type library. Is there some reason why you can't use ODBC? One of its benefits is that Access is not required to reside on the target machine.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
thanks DavidCrow,
unfortunately the program we are coding has a lot of legacy code and libraries in it which clash with a lot of new libraries. We have found that we can use the automation features in Office which don't cause these clashes.
I've already added the type library however I'm not sure the order in which I create the various objects and also what (if any) parameters I need to pass into their constructors. If you could give me any guidance on this it would be most helpfull.
cheers,
Andy
|
|
|
|
|
Unless you are needing something specific from Access (e.g., form, query, report), I think it would be easier to use DAO. Look in the C:\Program Files\Common Files\Microsoft Shared\DAO folder for the type library. Unfortunately the only example I could put together is in VB.
It's helpful to use VB's Object Browser and the C:\Program Files\Common Files\Microsoft Office\Office\1033\Acmain9.chm help file for figuring out classes and objects from the type library.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Yes these are all possible. There are some good articles with ADO classes to facilitate this by Carlos Antollini in the database section.
|
|
|
|
|
I'm trying to load a .db file as a custom resource and then write it out at runtime. I can load the .db and get a resource id and it builds fine, but can't figure out how to write the file out at runtime.
Is this even possbible?
Thanks in advance,
Ron
|
|
|
|
|
Some months ago I used this code to write a resource to a file:
FILE *outfile;
if (outfile = fopen(OutDLL, "wb"))
{
fwrite(dll, 1, dll_size, outfile);
fclose(outfile);
}
dll is a void* -pointer to the resource, dll_size the size of the resource
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks,
What I don't understand is how to address the resource. For example, I have a resource ID IDR_DB that I loaded at design time. How do I read it so as to write it to a file.
Thanks for help,
Ron
|
|
|
|
|
rlepine wrote:
Is this even possbible?
Yes. See here for an example.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|