|
I'm writing a program in c whose output is directed to a file (i.e. myprog > myfile).
My problem is that whenever I print a newline character, printf("\n"), the program outputs both a carriage return and a newline. So while the output should have just one character whose value is 10, the program outputs a 13 followed by a 10.
I this this might have something to do with Windows XP. Has anyone else heard of this?
I would greatly appreciate ANY help that can be offered.
Thanks,
Steve
|
|
|
|
|
SHaroz wrote:
My problem is that whenever I print a newline character, printf("\n"), the program outputs both a carriage return and a newline.
This is the character secuence used to denote "new line" in MS-DOS and derived products (like Windows XP). It's handled by the CRT (C RunTime library) - whenever it sees a LF, it emits CRLF.
To get "correct" line endings, open the file in binary mode. If, like in your example, it's supposed to work even with stdout, I believe you have to freopen "CONOUT$" (or whatever it's called - look up the docs for CreateFile).
++luck;
|
|
|
|
|
I tried mystream = freopen("myfile.out", wb, stdout) and it worked. The newline prints as one character. My problem is that I don't know how to find the file that stdout points to. I could avoid that if I knew a way to simply change the mode of stdout. I also thought that if the program is run like this "myprog > output.txt", argv[2] would be "output.txt". But that didn't work.
Keep in mind that this needs to be ANSI compatable, so I can't use any function that starts with an underscore (i.e. _setmode).
I tried looking up "CONOUT", but found nothing.
Do you think you could offer any more advice?
Thanks,
Steve
|
|
|
|
|
SHaroz wrote:
Keep in mind that this needs to be ANSI compatable
You didn't say that in your original post.
If you need to stay within the bounds of ANSI C, and you still need to emit only LF when running on Win32 (which is an "illegal" Win32 EOL sequence), then you might try linking with binmode.obj.
If that doesn't work, the only thing I can come to think of is to do your output to an internal string buffer, and then resort to fwrite.
++luck;
|
|
|
|
|
I have a program that plays multiple WAVS at the same time. What I cant figure out how to do is adjust the volume levels and panning for each individual WAV during playback. The only info Ive found is about changing the master WAV device volume. Can someone shed some light on how I can change the volumes and pans of individual WAV files (all of which are playing through the main WAV device output)?
Thanks!
Emil
|
|
|
|
|
I think you should look into using the directxsound stuff.. sounds like your limited without it. No pun intended!
Lata
|
|
|
|
|
I have a dialog that maintains a color swatch that is set/modified through MFC's CColorDialog.
It works ok, but when I want to initialize the color swatch in the OnInitDialog(), my color swatch is just the default (black) color I assigned during creation.
Also, when I pop-up the CColorDialog or move anything over my parent dialog, the color-swatch color is lost (resorts back to default black color).
How do I repaint the color swatch in OnInitDialog() and how do I keep my color swatch from loosing its color when other windows move over (repaint) the are it occupies?
Thank you much!
Johnny
Here are some details:
The color swatch is a picture control, Rect property, with IDC_MODEL_COLOR as its name.
I use this fn to update the swatch when CColorDialog returns (IDOK)
// update the color swatch with the RGB color value
void CGraphicsParameters::SetModelColorSwatch(COLORREF rgbColor)
{
CBrush swatch;
swatch.CreateSolidBrush(rgbColor);
CClientDC dc(this);
dc.FillRect(&m_ModelColorSwatch, &swatch);
}
I also call this fn from within OnInitDialog() -- that's when I noticed the problem.
Please help.
Thank you
|
|
|
|
|
You should be painting the colour swatch in OnPaint.
"Pretending to guide me, you led me astray,
And I don't want to fall into your kind of ways." "Melt", Front 242
|
|
|
|
|
Hi Daniel,
I modified my dialog's code to trap the WM_PAINT messages in OnPaint(), but I am still having problems initializing my dialog and the strange case when I do this to my MODELESS dialog:
1) place another window (dialog) object over my Color Swatch client area
keeping it over my Color Swatch
2) Set focus to my dialog with the Color Swatch -- don't move
3) Without moving either dialogs, toggle focus between the two
** the color swatch resorts back to the default (black) color.
Would you know what is going on and what I need to do?
Thanks.
Johnny
Here is what I have now:
//////////////////////////////////////////////////////
// CGraphicsParameters dialog -- .H
class CGraphicsParameters : public CDialog
{
// Other stuff left out for brevety
private:
// use to display colors as a sample swatch on the dialog
COLORREF m_ModelColor;
CRect m_ModelColorSwatch;
// Construction
public:
// use to display colors as a sample swatch on the dialog
void SetModelColorSwatch(COLORREF rgbColor);
}
//////////////////////////////////////////////////////
// CGraphicsParameters dialog -- .CPP
BOOL CGraphicsParameters::OnInitDialog()
{
CDialog::OnInitDialog();
// other dialog initialization goes here
// Initialize the color swatch rectangles - for later painting
// Calculate true location of the color swatch
// Get a pointer to CWnd
CWnd* pModelColor = GetDlgItem(IDC_MODEL_COLOR);
// Find its location on screen
pModelColor->GetWindowRect(&m_ModelColorSwatch);
// Store client coordinates
ScreenToClient(&m_ModelColorSwatch);
m_ModelColorSwatch.DeflateRect(2, 2, 1, 1); // for the sunken control setting
SetModelColorSwatch(m_ModelColor);
return TRUE;
}
void CGraphicsParameters::OnPaint()
{
SetModelColorSwatch(m_ModelColor);
CDialog::OnPaint();
}
// update the color swatch with the RGB color value
void CGraphicsParameters::SetModelColorSwatch(COLORREF rgbColor)
{
CBrush swatch;
swatch.CreateSolidBrush(rgbColor);
CClientDC dc(this);
dc.FillRect(&m_ModelColorSwatch, &swatch);
}
|
|
|
|
|
I did a quick test using the same code as you have here and it worked, so I suggest looking to see if m_ModelColor is set to black somewhere.
"Pretending to guide me, you led me astray,
And I don't want to fall into your kind of ways." "Melt", Front 242
|
|
|
|
|
Hi!
I have a VC++ application which works by itself. I need to convert it into a DLL so that i can call it from VB. I created a new win32 dll and added the source files and the header files to the project. THe application consists of many classes and has a main funciton as starting point. I used the _stdcall calling convention before the main function and declared the function prototype in a header file. The dll compiled without any errors.But when i try to call the dll form VB the runtime error 453 The function not found in the specified dll file pops up
I am a beginner in the VC++ and have very little knowledge of the language.
can u please suggest any solution to the above problem
Thanx
|
|
|
|
|
What you really wan't to do is to convert it into a Active-X control, trust me.
"You can stand all night at a redlight anywhere in town, hailing Marys left and right but none of them slow down. I've seen the best of men go past. I don't wanna be the last..."
|
|
|
|
|
Did you export your function by typing
extern "C" __declspec(dllexport) MyExportedFunction( );
?
|
|
|
|
|
I have used the _stdcall convention since from the help file i reckoned that _stdcall convention is compatible with VB 6
|
|
|
|
|
I had used the _stdcall convention since it is compatible with vb so i need to use the 'c' extern too?
|
|
|
|
|
Hmmm, seems like I read over the VB stuff. So I try it again
You do right in using the _stdcall convention. But the fact is that _stdcall leads to an exported function name that differs from your declared one.
So if your function is declared as
int __stdcall func (int a, double b),
the decorated name is _func@12 (12 is the number of bytes in the argument list).
Thus you either call it that way or you declare an alias in the EXPORT section of your .def file:
...
EXPORT
Func = _func@12
...
Then you can use the name Func in your VB app.
|
|
|
|
|
Hy there,
i'me looking for infos like tutorials and workshop on programming plug-ins for the internet explorer. How can I access to the favorites and how can i make a button with my functionality? These questions should be answered through the tutorial.
Thanks and regards
boa
|
|
|
|
|
|
boaconstrictor wrote:
i'me looking for infos like tutorials and workshop on programming plug-ins for the internet explorer.
<windir>\Program Files\Microsoft SDK\Samples\web\bits
This is a pretty cool example using BITS (background downloading). You need XP to run BITS, however, this code is a IE Plugin, so it could help you.
Good luck.
R.Bischoff | C++
.NET, Kommst du mit?
|
|
|
|
|
|
I've written a browser helper object that passes the HWND and IWebBrowser2* of an IE window to my dialog-based MFC app.
I need to use the IWebBrowser2* in my app, but doing so would (and does) cause an access violation. How can I use the information I have to create a valid IWebBrowser2* that still references the same instance of IE??
- KH
|
|
|
|
|
khan2000 wrote:
How can I use the information I have to create a valid IWebBrowser2* that still references the same instance of IE??
You can't, you're trying to pass a pointer between two processes (IE and your MFC app). Each process has its own memory space, and cannot see memory in other processes via a simple pointer.
You'll need to create your own communication system between the BHO and the dialog, and have the dialog tell the BHO what IWebBrowser2 methods to call.
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
You can use the marshalling feature of the COM. It's not a piece of cake, but it works, when you do it correctly. The trick is in two functions:
CoMarshalInterface and
CoUnmarshalInterface
I never did it interprocess, so you have to make your own research, but the princip is following - in app 1, in your case the browser helper object you will create the IStream* through function CreateStreamOnHGlobal . This IStream* you should pass to the CoMarshalInterface with your IWebBrowser2* . After succesfull call, you will have all required marshalling properties stored in a global memory stream.
Look for the GlobalAlloc();GlobalLock();GetHGlobalFromStream() etc functions for description how to work with that kind of shared memory and how to pass it between process boundaries.
Then in second process you'll get somehow the IStream* back, put it to the CoUnmarshalInterface to retrieve the IWebBrowser2* back.
So hope this helps and let the force be with you...
|
|
|
|
|
Hello everyone! I recently came upon a very helpful article on this site which detailed the use of stacked dialog pages to create a netscape-like prefrences design. After working around with the code for a little while, I got exactly the results I needed, except for one thing: I do not know how to access a control within one of the stacked pages from the main dialog.
Let me explain: what I intend to do is automatically set focus to a control within each of the property pages as the user selects the name of the page from a list box. For example, they may select temperature (It's a conversion program), and then the temperature pane will appear within a little frame I've created. However, when I try to set focus to a control within that pane, I have trouble. The problem only occurs when I try to access controls inside the pane from the main dialog. Does anyone have any idea on how I might be able to get this working? Thanks.
Btw, I've provided a link to a screenshot of my program, so you can get an idea of what I'm going for. I've also included a link to the page where I found the excellent tutorial on stacked dialogs.
Screenshot of my program[^]
Stacked Dialog Tutorial[^]
"Ignorance is the sin of the many, whereas knowledge is the salvation of few."
Aanidaani
|
|
|
|
|
In the list box 'selection changed' handler, have it tell the dialog handler for the frame containing the control you're interested in to set the focus to a particular item. It goes like this: list box -> frame dialog handler -> set focus.
Software Zen: delete this;
|
|
|
|