|
Hello guys,
I want to read the content of a textbox (a path) and then edit a file at this path.
The type of textbox->Text is System::String^ but file manipulating functions all need char* type parameters. How can I cast the text of the textbox into a char* variable, or are there newer functions than fopen(), fprintf() and so on, which work with managed type variables?
Thanks and best wishes,
Manfred
|
|
|
|
|
Hi,
in .NET you can do most of not all text processing using the String type; have a look at
the File and/or FileInfo classes.
|
|
|
|
|
array<wchar_t>^ szArray = strPath->ToCharArray();
char buffer[50]={0};
int i = 0;
for each(wchar_t ch in szArray)
buffer[i++] = ch;
Nigah M Manzoor
|
|
|
|
|
Thanks, it's working now
|
|
|
|
|
It is giving an error undeclared identifier i dont know why ?
I am making Win32 Window through WINAPI , WNDPROC, WNDCLASSEX now, in
WNDCLASSEX structure i have define "static LPCTSTR szAppName= L"OFWin""
WindowClass.lpszClassName= szAppName;
So wat to do in order to resolve it. ?
Headers windows.h is included.
|
|
|
|
|
Why is the compiler looking for "OFWin" as an identifier when
"OFWin" is characters in a string?
This compiles for me:
static LPCTSTR szAppName= _T("OFWin");
WNDCLASSEX wce;
wce.lpszClassName = szAppName;
Also...
static LPCTSTR szAppName= L"OFWin";
should be
static LPCTSTR szAppName= _T("OFWin");
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am using Visual c++ NEt 2005, I need to set the title of my DataGridView when I printed it using gridDrawer dll but I can't.
Who have try to put a title to his printed DataGridView using GridDrawer dll. I need help
|
|
|
|
|
If you are talking about the Article here on CodeProject you should ask the question in the forum at the bottom of the article.
led mike
|
|
|
|
|
Can i use a beforeNavigate2 event with a webbrowser form contorl?
I have two forms with webbrowser controls. When I click on a link in webrowser1, the page should be displayed in webBrowser2.
to do this i wish to use beforenavigate2 to cancel the request and then use the url to open in webBrowser2.
How can I accoplish this?
|
|
|
|
|
Hi. I'm using Visual Studio 2005 C++/CLI. I have a file that has its contents read into an array, one line of the file per element of the array. There may be 10 elements to read or 10,000 elements to read. I would like to define the array size dynamically by reading each line of the file, counting until all the lines are read. Then I want to go back to the begining of the stream but there is no Seek() function. I tried streamReader->Close() and then another streamReader = gcnew StramReader(fileStream) but that doesn't work. Can I reset the streamReader back to the beginning?
Thanks
Buck
|
|
|
|
|
I think you can access the Seek method through the StreamReader's BaseStream property. I'm not by a C++ compiler so I can't test this.
Try this out:
FileStream* fs = new FileStream(S"YourFile.txt", FileMode::???, FileAccess::???);
StreamReader* sr = new StreamReader(fs);
sr->BaseStream->Seek(0, SeekOrigin::Begin);
I think you will also need to call sr->DiscardBufferedData() after the Seek or you will get unexpected results.
|
|
|
|
|
Thanks Robert,
Yes, that works.
The key here is the sr->DiscardBufferedData() otherwise the sr->BaseStream->Seek() function does nothing.
Buck
|
|
|
|
|
Hello guys,
I'm trying to execute a *.exe file from an own win api. Of course I looked through the internet but all i could find was ShellExecute() and CreateProcess() which, for any reason, don't work in VC++2008. Do I need to include any special library files or headers to get access to these functions, or is there another way to start a program from my win api?
Thanks ans best wishes,
Manfred
|
|
|
|
|
Hi,
if you want to create a process, maybe you should read up on the Process class?
|
|
|
|
|
Austrian_Programmer wrote: Do I need to include any special library files or headers to get access to these functions
ShellExecute()
Header - shellapi.h
Import library - shell32.lib
CreateProcess()
Header - Declared in Winbase.h; include Windows.h.
Library - Use Kernel32.lib.
|
|
|
|
|
Thanks, but you need windows.h in both cases.
I tried the ShellExecute() function with the included header and library, but nothing happens, the specified program didn't start.
<br />
#pragma once<br />
#pragma comment(lib, "shell32.lib")<br />
<br />
#include <windows.h><br />
#include <shellapi.h><br />
<br />
<br />
char *pcOp = "open";<br />
char *pcPath = "calc.exe";<br />
ShellExecute(NULL, (LPCWSTR)pcOp, (LPCWSTR)pcPath, NULL, NULL, SW_SHOWNORMAL); <br />
</shellapi.h></windows.h>
As I run this code I didn't get any error messages but nothing happened.
What am I doing wrong?
|
|
|
|
|
Austrian_Programmer wrote: As I run this code I didn't get any error messages but nothing happened.
What am I doing wrong?
What was the return value from ShellExecute?
led mike
|
|
|
|
|
Austrian_Programmer wrote: ShellExecute(NULL, (LPCWSTR)pcOp, (LPCWSTR)pcPath, NULL, NULL, SW_SHOWNORMAL);
As I run this code I didn't get any error messages but nothing happened.
What am I doing wrong?
Casting char*s to wchar_t*s is not good.
You shouldn't use casts unless absolutely necessary. If it doesn't compile without
the casts, then I recommend looking at the types involved before covering the problem
with a cast.
Mark
|
|
|
|
|
Can we use the directshow methods in VC++ windows forms application. I have worked in VC++ MFC using Dshow methods and dont know how to use in VC++ Windows forms application. I got linker error when I use the Dshow methods, also I specified all the libraries in Project properties. Please advice.
Many thanks in advance.
|
|
|
|
|
What are the errors exactly?
Mark
|
|
|
|
|
1>------ Build started: Project: AV2USB, Configuration: Debug Win32 ------
1>Linking...
1>AV2USB.obj : error LNK2020: unresolved token (0A00000E) IID_IAMStreamConfig
1>AV2USB.obj : error LNK2020: unresolved token (0A00000F) IID_IBaseFilter
1>AV2USB.obj : error LNK2028: unresolved token (0A000011) "extern "C" void __stdcall VariantInit(struct tagVARIANT *)" (?VariantInit@@$$J14YGXPAUtagVARIANT@@@Z) referenced in function "private: void __clrcall AV2USB::Form1::button4_Click(class System::Object ^,class System::EventArgs ^)" (?button4_Click@Form1@AV2USB@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>AV2USB.obj : error LNK2020: unresolved token (0A000012) IID_IPropertyBag
1>AV2USB.obj : error LNK2020: unresolved token (0A000013) IID_ICreateDevEnum
1>AV2USB.obj : error LNK2020: unresolved token (0A000014) IID_ICaptureGraphBuilder2
1>AV2USB.obj : error LNK2020: unresolved token (0A000015) IID_IGraphBuilder
1>AV2USB.obj : error LNK2001: unresolved external symbol IID_IAMStreamConfig
1>AV2USB.obj : error LNK2001: unresolved external symbol IID_IBaseFilter
1>AV2USB.obj : error LNK2019: unresolved external symbol "extern "C" void __stdcall VariantInit(struct tagVARIANT *)" (?VariantInit@@$$J14YGXPAUtagVARIANT@@@Z) referenced in function "private: void __clrcall AV2USB::Form1::button4_Click(class System::Object ^,class System::EventArgs ^)" (?button4_Click@Form1@AV2USB@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>AV2USB.obj : error LNK2001: unresolved external symbol IID_IPropertyBag
1>AV2USB.obj : error LNK2001: unresolved external symbol IID_ICreateDevEnum
1>AV2USB.obj : error LNK2001: unresolved external symbol IID_ICaptureGraphBuilder2
1>AV2USB.obj : error LNK2001: unresolved external symbol IID_IGraphBuilder
1>E:\GUI\AV2USB\Debug\AV2USB.exe : fatal error LNK1120: 14 unresolved externals
1>Build log was saved at "file://e:\GUI\AV2USB\AV2USB\Debug\BuildLog.htm"
1>AV2USB - 15 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
|
|
|
|
You've included Strmiids.lib and Dxguid.lib in your build?
|
|
|
|
|
I have added Strmiids.lib already and tried including Dxguid.lib but still I got the same linker errors. Please help me if I miss something. The other libraries included are strmiids.lib strmbase.lib winmm.lib SetupApi.lib strmbasd.lib Dxguid.lib Quartz.lib ole32.lib. In addition to this there are default inherited libraries. They are as follows
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib
More interestingly, when I remove the libraries from the Project Properties->Linker->Input, I got the same errors. Please advice.
modified on Friday, June 27, 2008 6:13 AM
|
|
|
|
|
hmm the only thing I can think of is you've got the wrong SDK.
What version of Visual Studio?
What SDK version are you using?
Mark
|
|
|
|
|
Mark Salsbery wrote: What version of Visual Studio?
Visual Studio 2005
Mark Salsbery wrote: What SDK version are you using?
Microsoft Platform SDK for Windows Server 2003 R2
For your information, everything works fine with VC++ MFC and the problem now facing is with VC++ Windows application forms.
|
|
|
|