|
mstsc
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi,
I'm using CFileDialog to display a list of files to open, but when I change the extension type I don't get a displayed list of the newly associated files.
CFileDialog fileOpen(TRUE, "dat", "*.dat", OFN_EXPLORER | OFN_FILEMUSTEXIST, "Data Files (*.dat)|.dat|Doc Files (*.doc)|.doc|All Files (*.*)|.*||");
if(IDOK == fileOpen.DoModal())
{
....
}
It really is as simple as that, but the explorer doesnt seem to want to display the files associated with the new extensions.
Any ideas?
TIA
Tony
BTW - I'm using Visual Studio 2003 on an XP machine
modified on Monday, May 24, 2010 5:42 AM
|
|
|
|
|
Resolved.......
.dat should read *.dat etc.....
|
|
|
|
|
I have multiple excel.exe running on my system . When I called GetActiveObject() method then I am able to get only the one excel.exe not all . So please tell me how can I get all the running excel.exe
Trioum
|
|
|
|
|
from what Ive seen GetActiveObject() is only going to get one instance. If you are looking for a particular instance, you could try looping :-
GetActiveObject()
Is This instance what Im looking for ?
If No CLose the excel instance
repeat until you find the excel instance you want
I was thinking that you could enumerate windows with Excel in the title, somehow close the ones you dont want (assuming you can detect the one you do want by the window title), then do a GetActiveObject()
sorry .. maybe someone else has a better idea
|
|
|
|
|
No your idea is failed every time I got the same Excel. And I cannot close the running excel.exe
Trioum
|
|
|
|
|
|
btw how did you implement either of my ideas ? and
trioum wrote: And I cannot close the running excel.exe
why not ? obviously if you cant close any excel instance you dont want then you'll never get to the one you do want.. what do you have so many zombie excel instances ?
'g'
|
|
|
|
|
I have to work with mulitple excel files not one dude
Trioum
|
|
|
|
|
do you know if GetActiveObject() returns a reference to the Excel instance that 'has focus' or 'is currently active' ?
If that were the case, AND you could distinguish which excel instance was which by the Window title, then you could build a workable solution
a) enumerate all the excel instances and look at their window titles
b) force the instance you want (by window title) to come to the front ie give it focus
c) then do a GetActive Object
somehow I dont think its that easy - the GetActiveObject may have its own way of looking at the ROT or process table, not just the 'active excel instance' - thats confirmed by looking further : MS KB 238975 - http://support.microsoft.com/kb/238975[^]
says "NOTE: If there are multiple instances of an automation server running at the same time, the GetActiveObject() API function returns the IDispatch pointer to the instance that was first running."
So I dont think you're going to be able to do it
|
|
|
|
|
When I use MFC New Feature pack (VC++ 2010) e.g. MFC Property Grid control in my application by adding them directly to resource designer while running the application, MFC new controls appear with no style but the controls Like CButton appear correctly?
What's the problem , please Help
|
|
|
|
|
Hi
I want to change the image of button on mouse over. When the mouse pinter will be on button it should change the image of the button and once pointer come out from button it should come to its original state. My button havinf owner draw properties and I want to create the button at runtime.
Please provide me some same code
Thanks
|
|
|
|
|
|
I Have a CString which contains port names.
CString cs = "COM1";
char portname[5];
1. What is the memory representation of cs above (I have this question since I think it is multibyte/wide char)?
2. How to copy above cs into portname ? I need portname to contain
{'C','O','M','1','\0'}
Thanks
JC
|
|
|
|
|
|
TCHAR path[ MAX_PATH ];
Cstring str;
_tcscpy(path, str);
|
|
|
|
|
1/
The memory representation will change depending on whether the UNICODE define is there or not. The default changes depending on which version of Visual studio you have. VS6, it's char. I think all later ones, it's w_char, or 16bits.
2/ There's a conversion to LPCTSTR operator in the CString class, so you can pass it to const TCHAR * parameters of other functions. So, your question is trivial:
lstrcpy (szBufferOut, sMyString);
Have a look at the following article for more help:
The Complete Guide to C++ Strings, Part I - Win32 Character Encodings[^]
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
Hi,
You've got two problems here:
- Converting from potentially wide to narrow charcaters
- Getting rid of any const
The first means that you can't use something like _tcscpy and TCHARs as you want real, honest, chars, not chars or wchar_ts depending on some preprocessor macro. The second means you've got to do a real copy and you can't just use an implicit conversion.
To solve the second problem you've got to do a copy. To solve the first you either copy the string using wcstombs or strcpy depending on whether the CString is encoded as unicode as not. You can either use the preprocessor to select which function you use, but that's really sucky like most uses of the preprocessor in C++ (avoid it like the plague) or you can use function overloading:
void to_narrow( const CStringA &to_convert, char *out )
{
...
}
void to_narrow( const CStringW &to_convert, char *out )
{
...
}
I haven't bothered including the code as there's another way you can do the conversion which relies more on the C++ standard library and has less pointers flopping about and confusing the issue. In this version I'm returning a std::vector<char> as it sorts out any memory management for the caller:
std::vector<char> to_narrow( const CStringA &to_convert )
{
const char *convert_start = to_convert;
const char *convert_end = convert_start + to_convert.GetLength() + 1;
return std::vector<char>( convert_start, convert_end );
}
std::vector<char> to_narrow( const CStringW &to_convert )
{
const wchar_t *convert_start = to_convert;
std::vector<char> output( to_convert.GetLength() * 4 + 1 );
output.resize( wcstombs( &output[ 0 ], to_convert, output.size() ) );
return output;
}
The supperfluous +1s everywhere are due to CString::GetLength not including the terminating '\0' character in the length. The *4 is just in case Microsoft ever support utf-8 as a character set - it gives the oodles of space for really weird characters
Any questions just shout.
Cheers,
Ash
PS: This code was written from memory and isn't tested, there might be some problems but the idea's sound and in use all over the place.
|
|
|
|
|
Hi All,
I am trying to get a splitter window for MDI when a Menu Item in Menu is clicked. The splitter window is been created but when i am trying to drag that Splitter it is not able to split also it is not performing the events of the pane. (i.e) if in Pane2 of the splitter i am having a Button Control it is not been handled.
Help me out!
Thanks,
Uday.
Here is the Code.
-----------------
void CMainFrame::OnMytreeTree()
{
CCreateContext ctx;
ctx.m_pNewViewClass = RUNTIME_CLASS(CudayView);
// GetActiveDocument() call before you destroy m_splitter.
ctx.m_pCurrentDoc = GetActiveDocument();
//ASSERT(ctx.m_pCurrentDoc!=NULL);
// m_pSplitter !=NULL when there is a visible splitter.
if (m_pSplitter)
{
// Destroy splitter window.
delete m_pSplitter;
m_pSplitter = NULL;
// Create and initialize CMyView.
SetActiveView((CView*)CreateView(&ctx));
GetActiveView()->OnInitialUpdate();
}
else
{
if(m_pSplitter == NULL)
{
//MDIGetActive()->DestroyWindow();
// Create new splitter window.
m_pSplitter = new CSplitterWnd;
if (!m_pSplitter->CreateStatic(this, 1, 2))
{
TRACE0("Can't create splitter window.\n");
return;
}
else
{
if ((!m_pSplitter->CreateView(0, 0,
RUNTIME_CLASS(CMyTreeView),
CSize(200, 0), &ctx))
||(!m_pSplitter->CreateView(0, 1,
RUNTIME_CLASS(CFirstView),
CSize(500, 0), &ctx)))
{
TRACE0("Can't create one of the splitter panes.\n");
return;
}
// Initialize the two panes (each containing a view
// associated with the current document).
((CView*)m_pSplitter->GetPane(0, 0))->OnInitialUpdate();
((CView*)m_pSplitter->GetPane(0, 1))->OnInitialUpdate();
SetActiveView((CView*)m_pSplitter->GetPane(0, 0));
}
}
}
// Redisplay frame.
RecalcLayout();
}
|
|
|
|
|
Hello everybody.
I'm trying to use OCILIB driver for oracle under Mvisual studio 6 and i need some help to accomplish some duties.
in my work i need to include a lib file a dll file and a header file; like
. oclib.h
. ociliba.dll
. ociliba.lib
to include the header file, i put the file under "C:\Program Files\Microsoft Visual Studio\VC98\Include"
the question is: how could i use the dll and the lib files in my project (i'm using visual studio 6)
it's a kind of an easy task but i never tried to include dll or lib files into my projects.
Thank you very much
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
One way is like this - its suitable for small projects I guess :-
a) go to Project Settings (ALT F7)
b) Select The Link Tab
c) Set Category to Input
d) In the Object/library modules box, put oci.lib and a space after it - put it at the front for now unless there is a 'collision' in the build/link stage
e) In the Additional Library Path box, enter in the path to the .lib module
Obviously you include the ocilib.h file with a #include "ocilib.h" ... not sure If I agree with where you put it .. I usually put 3rd party modules in a '3rdParty' Folder
Projects
\3rdParty
\bin <- Libs, dlls
\inc <- Headers
In your case they are probably under the Ora92 (or whatever version) directory - they could be left there
To Pick up the headers from the structure above or where you have them, you could :-
a) go to (again,under project setting) C++ Tab,
b) Select Category 'Preprocessor'
c) Put the directory ie drive:\Projects\3rdParty\inc in the additional include directories
You can also change (independantly) the settings or ALL projects, by going Tools -> Options -> Directories, and using the 'Show Directories For' dropdown and adding the directories for include files, library files etc - some people prefer this approach.
For larger projects, I tend to use a modified version of the 1st approach, but I allow for different versions of components by using environment settings (that means I dont need to change the basic build within a project), but see if you can get going in 'simple mode' first
hope this helps
'g'
|
|
|
|
|
Thx for the answer.
it works now. thx you verry much for this help.
"The Ultimate Limit Is Only Your Imagination."
modified on Sunday, May 23, 2010 6:54 PM
|
|
|
|
|
not sure where thats coming from, and Im sure you'll appreciate, trying to debug something like this remotely is hard
- have you started a new project from scratch or are you extending something else you've found ?
- have you just installed MSVC and proved it can compile a simple 'hello world' ?
What kind of project are you attempting to create - console, gui/MFC, Dialog box - not that it should make too much of a difference
If you're a rank beginner, I do feel your pain, and yes, it is hard to find your way around .. I often find the safest way to start with a new API for example is to build myself a little console test harness - start with a console 'hello world' program, build that, then start adding eg the oci stuff to it it.. when thats done and working, then think about applying that knowledge to something bigger/the main project .. that way if something goes wrong, you always have your test harness to refer to - its not quite 'unit testing' but a good start
Its been a long time since Ive worked with oci (and never 'directly') - tell me about what you're trying to do and I might be able to suggest an approach
'g'
|
|
|
|
|
for that error it was the " that i added to the path when including the lib. now it's gone when i erase it
For the oci, i m trying to put on screen the data from an Oracle DB using C++ and this to integrate it into a larger team work. so my part is to begin with the ocilib driver.
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
Hi, I am a C++ beginner. I have an NT Service I need to publish on the net for download but I don't want any one to be able to start except me or the one I authorize. When you download the service executable you could install the service but you should not be able to start it. One of the ideas is to protect the service executable with password, this way, in theory, only the one who has the password can start the service. Lots of EXE Password protectors on the net, but once I use one of them to protect the service executable the service doesn't start at all. The reason is obvious; NT services has no message pipe a user could use to enter the password. I even used Themida to protect the service as described on their KB (they say their software can protect NT Services) but looks like Themida actually corrupts the service executable too as it doesn't start anymore. I have the source code of the service and I use [service /i] and [service /u] to install/uninstall the service, but I don't know how to pass the password as a command line parameter to the service when I start it. the SCM attempt to start it.
If the password protecting is a bad idea, could some one guide me on how to reach my goal, my goal is: my service should not be started by anyone except me.
Thanks
modified on Sunday, May 23, 2010 3:52 PM
|
|
|
|
|