KSetButton

Hi,

when i was trying this kind of button, it gave me the following error, file not found:

Cannot open type library file: '..\..\controls\kSetEditor\kSetEditor.tlb': No such file or directory

AND i searched for that .tlb file and even i could not find it.

This KSetButton is an article presented in the Buttons section of CG.

I was compiling the demo project and i got into this error.

Is there any solution?
[472 byte] By [danandu] at [2007-11-20 11:00:41]
# 1 Re: KSetButton
Did you ask the author of this article about possible reasons of your trouble?
VictorN at 2007-11-10 22:27:28 >
# 2 Re: KSetButton
I had posted a comment on this regards in the article. But i didnt got any reply.
danandu at 2007-11-10 22:28:38 >
# 3 Re: KSetButton
I just checked out this article. There are two parts to it 1) the demo project and 2) the source project.

The source project is an activex control. You need to compile this project first (i.e expand KSetButtons_src.zip and then compile it) and then register the control - there's reg_controls.bat that should help you.

Next, unzip the demo project source and compile it (you'll need to change the path of the .tlb file to point to the appropriate location of the .tlb that was created from compiling the src).
Arjay at 2007-11-10 22:29:30 >
# 4 Re: KSetButton
Hi,

When i open the src zip file it opens up into two: 1)kSetButton and 2)kSetEditor

And both of them are giving errors:
for 1)
error description for

kButton.cpp
E:\TUTORIALS\TutVC\TutVCPartII\XII Buttons\KSET Buttons\KSetButtons_src\kSetButton\kButton.cpp(295) : error C2664: 'GetProcAddress' : cannot convert parameter 2 from 'unsigned short [16]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

in

void _kButton::DetectTrackMouse()
{
m_pfTrackMouseEvent = (PTRF_TrackMouseEvent)GetProcAddress (GetModuleHandle(_T("user32")), _T("TrackMouseEvent"));
}

for 2)

error description:

kEdit.cpp
E:\TUTORIALS\TutVC\TutVCPartII\XII Buttons\KSET Buttons\KSetButtons_src\kSetEditor\kEdit.cpp(302) : error C2664: 'T2W' : cannot convert parameter 1 from 'const unsigned short *' to 'unsigned short *'
Conversion loses qualifiers
E:\TUTORIALS\TutVC\TutVCPartII\XII Buttons\KSET Buttons\KSetButtons_src\kSetEditor\kEdit.cpp(614) : error C2664: 'GetProcAddress' : cannot convert parameter 2 from 'unsigned short [16]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

in the code

STDMETHODIMP _kEdit::get_Text(BSTR* ppText)
{
USES_CONVERSION;
ATLTRACE2(atlTraceControls,2,_T("_kEdit::get_Text\n"));
*ppText = SysAllocString(T2W(m_pedit->text()));
return S_OK;
}

and

void _kEdit::DetectTrackMouse()
{
m_pfTrackMouseEvent = (PTRF_TrackMouseEvent)GetProcAddress (GetModuleHandle(_T("user32")), _T("TrackMouseEvent"));
}

Hence i am not able to compile them successfully.
I am using VS6.0
danandu at 2007-11-10 22:30:41 >
# 5 Re: KSetButton
Yes, there is a "bug" in the GetProcAddress call. The second parameter must be LPCSTR , not LPCTSTR! You should fix it.
VictorN at 2007-11-10 22:31:32 >
# 6 Re: KSetButton
I could compile the button solution, but got 191 compiler errors when compiling the editor solution (I don't have VC6, so I used VC7.1).
Arjay at 2007-11-10 22:32:42 >
# 7 Re: KSetButton
I had fixed the bug in GetProcAddress by removing the _T.

And i could successfully compile and get the .tlb file for kSetButton.

But with kSetEditor there it gives an error for unable to convert from const unsigned short* to unsigned short*

in code:

STDMETHODIMP _kEdit::get_Text(BSTR* ppText)
{
USES_CONVERSION;
ATLTRACE2(atlTraceControls,2,_T("_kEdit::get_Text\n"));
*ppText = SysAllocString((T2W(m_pedit->text())));
return S_OK;
}

as :

kEdit.cpp
E:\TUTORIALS\TutVC\TutVCPartII\XII Buttons\KSET Buttons\KSetButtons_src\kSetEditor\kEdit.cpp(302) : error C2664: 'T2W' : cannot convert parameter 1 from 'const unsigned short *' to 'unsigned short *'
Conversion loses qualifiers

how to correct this error.
danandu at 2007-11-10 22:33:41 >
# 8 Re: KSetButton
I had fixed the bug in GetProcAddress by removing the _T.Perhaps, I wrote about a "bug" not so clear/correct... :sick:
I meand the bug was in the KSetButton project: this project developer used GetProcAddress incorrectly (with the wrong parameter type).

But with kSetEditor there it gives an error for unable to convert from const unsigned short* to unsigned short*

in code:
...Try to use T2CW macro instead or cast the m_pedit->text() to unsigned short*
VictorN at 2007-11-10 22:34:37 >
# 9 Re: KSetButton
it gives:

Linking...
Creating library ReleaseUMinDependency/kSetEditor.lib and object ReleaseUMinDependency/kSetEditor.exp
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseUMinDependency/kSetEditor.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

this error.

what may be the problem.
danandu at 2007-11-10 22:35:45 >
# 10 Re: KSetButton
Have you tried to search MSDN for this error message?
VictorN at 2007-11-10 22:36:40 >
# 11 Re: KSetButton
yes and i got it as:

unresolved external symbol "symbol"

Code will generate this error message if it references something (like a function, variable, or label) that the linker cant find in all the libraries and object files it searches. In general, there are two reasons this error occurs: what the code asks for doesnt exist (the symbol is spelled incorrectly or uses the wrong case, for example), or the code asks for the wrong thing (you are using mixed versions of the libraries?some from one version of the product, others from another version).

Numerous kinds of coding and build errors can cause LNK2001. Several specific causes are listed below, and some have links to more detailed explanations.

..But i could not find the reason why _main is not found or why is it searching for that.

I tried searching for _main, even i could not find it.

Probably the author could answer for this...
danandu at 2007-11-10 22:37:43 >
# 12 Re: KSetButton
http://support.microsoft.com/kb/291952
VictorN at 2007-11-10 22:38:46 >
# 13 Re: KSetButton
I went through the link provided by you,

I found that it was an ATL project

And also i corrected for

If your project is an ATL project, there are two ways to fix the problem:
Remove _ATL_MIN_CRT from the list of preprocessor definitions to allow CRT startup code to be included: From the Build menu, choose Settings. Hold down the CTRL key while selecting all of the release configurations. On the C/C++ tab, choose the General category, and then remove _ATL_MIN_CRT from the preprocessor definitions edit box. -or-

...from the MSDN

Now I am able to compile the kSetEditor and generate the corresponding dlls.

I created controls folder as required in the path of the demo project for the .tlb import statement.

Then i compiled demo project successfully and run it also!.

Thanking you for all the way.

Its great work in the debug and as well as in the control.
danandu at 2007-11-10 22:39:46 >
# 14 Re: KSetButton
Thanks again:):wave:
danandu at 2007-11-10 22:40:44 >