|
Imtiaz Murtaza wrote: return TRUE;
You should return FALSE , if you want to set focus to a control in a dialog, from OnInitDialog .
As far as the selection issue is concerned I don't see any problem here. It's working here.
|
|
|
|
|
Hi,everyone. My application is based on Muti-Doc (VC6.0).
I created a controlbar in mainfrm (OnCreate()) and then created a tabcontrol in the controlbar (also in OnCreate()), then I created a TreeCtrl in the TabCtrl.
HTREEITEM hti1 = m_wndTree1.InsertItem(_T("Chapter1"));
HTREEITEM subroot1=m_wndTree1.InsertItem("section1",hti);
HTREEITEM hti2 = m_wndTree1.InsertItem(_T("Chapter2"));
Now I want to add "Chapter3" in the TreeCtrl by menu, what should I do???
If you can show some codes , that's better. Because I'm a begginner.
Thanks a lot.
|
|
|
|
|
wangpai wrote: HTREEITEM hti2 = m_wndTree1.InsertItem(_T("Chapter2"));
Um...
HTREEITEM hti3 = m_wndTree1.InsertItem(_T("Chapter3"));
seems obvious to me....
If you want a menu to add the item, then you need to put that code into the method called by a menu item.
|
|
|
|
|
I created the treectrl in mainfrm.cpp, and used ID_FILE_NEW_ADD menu item to do this work.
I add this to my codes:
void CMainFrame::OnFileNewAdd()
{
// TODO: Add your command handler code here
HTREEITEM hti3 = m_wndTree1.InsertItem(_T("Chapter3"));
}
But it didn't work.
|
|
|
|
|
Which didn't work InsertItem or event of ID_FILE_NEW_ADD
|
|
|
|
|
Ok, there is something I really don't get. I'm triing to use the function _strnset_s, but I get the compiler error : '_strnset_s': identifier not found, even with argument-dependent lookup.
The thing is that string.h is included in my project and at the line just before this one, I used strrchr wich need the same include and the compiler doesn't complain about this one. What did I do wrong?
here a very short version of my code:
stdafx.h :
#pragma once
#define WIN32_LEAN_AND_MEAN
headers
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
// Others
#include <stdio.h>
#include <string.h>
#include <afx.h>
Form1.cpp :
#include "stdafx.h"
#include "Form1.h"
Form1.h :
#pragma once
#pragma push_macro("GetObject")
#undef GetObject
#pragma push_macro("MessageBox")
#undef MessageBox
namespace VampireReader
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::IO;
using namespace System::Runtime::InteropServices;
using namespace System::Text;
private:
System::ComponentModel::Container * components;
void InitializeComponent(void)...
private: void fOpenFile()
{
csDest = strrchr( csFName, '\\' );
_strnset_s( csDest, sizeof(csDest), ' ', 1 );
}
|
|
|
|
|
Maybe you are pointing to a string.h from a previous sdk.
Right click on the include, open string.h, and search for "_strnset_s".
If it's not there you need an SDK update.
|
|
|
|
|
_strnset_s is found in C++/CLI of VS2005. Looks like you are using Managed C++ of VS2003 because "System::ComponentModel::Container* components;" is MC++ 2003 and "System::ComponentModel::Container ^components;" is C++/CLI 2005.
-- modified at 21:05 Wednesday 8th November, 2006
|
|
|
|
|
Thanks, I didn't thinked about that.
|
|
|
|
|
I am getting a linking error:
LINK : fatal error LNK1181: cannot open input file "C:\Sensors.obj"
and Can someone tell me how to fix it. Since Sensors.obj have nothing to do with my project. I don't have any sensors.h or .cpp files.
Will really appreciate the help
Thanks
Anony
|
|
|
|
|
Look through your project ( a find in files can do this for you ) and see why it's looking for this file.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks for the reply but it didn't work for this problem. When I do "FIND IN FILES" it gives, there is nothing like sensors.obj.
I am just hung up with the problem. What else I can do?
Thanks again
C++Prog
|
|
|
|
|
There must be a reference to it somewhere. Use windows explorer search or VS Find in Files feature to look for any file in your project that contains the text "sensors". If using Find In Files make sure you set the file type to *.*
|
|
|
|
|
Yeah, that's what I was advocating.
|
|
|
|
|
There has to be a reason that it's expecting to find this file, you searched for the word 'sensors' in the text of your entire project ?
|
|
|
|
|
Did you look in the project's .dsp file?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
no, will try that..
Thanks
C++Prog
|
|
|
|
|
Does anyone know how i can call a function I created inside a thread? Thanks a lot!
I have a class with a list object in it. I need to do some processing that's why
I created a thread which does that. I have created another function which accepts
3 or 4 strings inside the class...
void AddListItem(CString strbufffn, CString strbuffip, CString strbuffdate, CString strbuffstat);
note that inside the function im adding items to the CListCtrl of my List object
and i need the information processed by my thread to be passed to the function.
DWORD WINAPI ReceiveThread(LPVOID lParam)
{
//some processing here
//need to call the AddListItem here
}
Again thanks for the help!
|
|
|
|
|
In general you just call it. Be warned however; multithreading introduces many new and often unexpected complexities to an application. If you don't understand these complexities you're better off avoiding it. For example something as simple as incrementing a variable might not work as expected if more then one thread tries to "touch" it at the same time. If you've never heard of EnterCriticalSection , LeaveCriticalSection , InterlockedIncrement and many others, don't even consider using multiple threads.
Steve
|
|
|
|
|
Thanks but I already tried that and unfortunately it did not work. It had an error saying that the function is an external function or something.
|
|
|
|
|
This doesn't sound like a threading problem to me. Can you call the function at all even when no threading is used (in the same file as you do when threading is used)?
Steve
|
|
|
|
|
yes I can. I've been looking at every possible problem but it seems like the thread is it. the thread can't see the function i declared in the main class.
|
|
|
|
|
Llasus wrote: the thread can't see the function i declared in the main class.
The compiler knows nothing about threads. Threads are supported by the OS and the C-runtime library so the visibility of functions will not be effected. That's why I suggested putting the call to the function in the same file (and as close as possible) as the call made in the thread function: as location is an issue.
Steve
|
|
|
|
|
I tried putting the function in the same file as the thread and it still generated the same error as it cant see the function when called in the thread.
|
|
|
|
|
Perhaps if you posted some code and the exact error message text something might reveal itself.
Steve
|
|
|
|