|
How to get the delagate value via property
<pre>property MyCallback^ CallBack1
{
MyCallback^ get {return m_pCallBack; }
}
Private MyCallback^ m_pCallBack;</pre>
Thanks
|
|
|
|
|
|
Hi,
Is there any function that returns an index of a particular element in a numeric array.
Thanks
P.S. I am looking for an equivalent of MATLAB's find() function.
|
|
|
|
|
You can use a combination of std::find[^] and std::distance[^] in order to search for an element and get its index.
The standard algorithms will work both on standard containers and arrays. Here is a quick example for you, which demonstrates the usage of std::find and std::distance with std::vector and regular array:
int arr[] = {31, 53, 7, 9, 45, 20};
const int size = (sizeof(arr) / sizeof(arr[0]));
int* arr_beg = arr;
int* arr_end = arr + size;
std::vector<int> vec;
std::copy(arr, arr + size, std::back_inserter(vec));
std::cout << "\n Searching the array for element with value 7...";
int* res1 = std::find(arr, arr + size, 7);
if(res1 != arr_end)
std::cout << "\n The element is found at index: " << std::distance(arr_beg, res1);
else
std::cout << "\n The element is not found";
std::cout << "\n Searching the array for element with value 8...";
int* res2 = std::find(arr, arr + size, 8);
if(res2 != arr_end)
std::cout << "\n The element is found at index: " << std::distance(arr_beg, res2);
else
std::cout << "\n The element is not found";
std::cout << "\n Searching the vector for element with value 7...";
std::vector<int>::iterator it1 = std::find(vec.begin(), vec.end(), 7);
if(it1 != vec.end())
std::cout << "\n The element is found at index: " << std::distance(vec.begin(), it1);
else
std::cout << "\n The element is not found";
std::cout << "\n Searching the vector for element with value 8...";
std::vector<int>::iterator it2 = std::find(vec.begin(), vec.end(), 8);
if(it2 != vec.end())
std::cout << "\n The element is found at index: " << std::distance(vec.begin(), it2);
else
std::cout << "\n The element is not found";
I hope this helps. 
|
|
|
|
|
you can use std::find function.you need to include algorithm header file
for example if you have a vector containing some integers you can call it like this
vector<int>::iterator the_index = std::find( vcNumbers.begin(),vcNumbers.end(), number_to_search );
you can check if the index is valid by checking it against vcNumers.end().Something like this.
if( vcNumbers.end() != the_index) cout << *it;
hopes this helps
If u can Dream... U can do it
|
|
|
|
|
Please help. I haven't programmed unmanaged C++ in 10 years. I'm trying to re-educate myself but I don't seem to be having a lot of luck. I swear I just stepped into the twilight zone. This code:
#include <string>
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
std::string s = " ";
printf(s);
return 0;
}
...fails to compile with 2 errors: C2039 "string is not a member of std" and C2065 "'s' undeclared identifier".
So then I tried a "using namespace" declaration like this:
#include <string>
#include "stdafx.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string s = " ";
printf(s);
return 0;
}
...and I still get the C2065, though the C2039 is gone.
I also tried other ideas, like changing to . Nothing is working. What am I doing wrong??? I am using VS2010 on a Win7 (64bit) machine. Thanks for your help.
|
|
|
|
|
you cannot do printf( s) , instead you can do like printf( s.c_str() ) or cout << s ( make sure that yo include iostream ).
If u can Dream... U can do it
|
|
|
|
|
The precompiled header (stdafx.h ) should always be the first header included. Also dump the printf . Try code like this:
#include "stdafx.h"
#include <iostream>
#include <string>
int _tmain(int argc, _TCHAR* argv[])
{
using namespace std;
string s = "Hello, world!";
cout << s << endl;
return 0;
}
Steve
|
|
|
|
|
Re-ordering the #includes did the trick. I had read about the use of printf/cout but I hadn't gotten to that point since I couldn't even get my variable declaration to compile. Thanks for the pointers.
|
|
|
|
|
Hi all!
I'am use ms sql server 2000 and msvs 2005 (visual c++)
Need to execute stored procedure in c++ client code.
On line
err = cmd.MoveFirst();
it's failed, because m_spRowset is NULL,
BUT then I remove line
update dbo.States set Name = '@' where StateId = 3 from stored procedure - it's OK?
What's wrong here?
Thanks for help!
sp code:
<br />
go<br />
alter procedure trans_GetList<br />
as<br />
begin<br />
update dbo.States set Name = '@' where StateId = 3<br />
<br />
select StateId from dbo.States<br />
end<br />
go<br />
c++ code:
<br />
CDataSource con;<br />
<br />
HRESULT err;<br />
<br />
err = con.OpenFromInitializationString(L"...");<br />
<br />
CSession session;<br />
<br />
err = session.Open(con);<br />
<br />
CCommand < CDynamicParameterAccessor, CBulkRowset, CMultipleResults > cmd;<br />
<br />
err = cmd.Create(session, L"exec dbo.trans_GetList");<br />
err = cmd.Prepare();<br />
<br />
void *bufCmd = 0;<br />
<br />
err = cmd.BindParameters(&cmd.m_hParameterAccessor, cmd.m_spCommand, &bufCmd);<br />
err = cmd.Open(0, 0); <br />
err = cmd.MoveFirst();
<br />
while(err == S_OK)<br />
{<br />
...<br />
err = cmd.MoveNext();<br />
}<br />
<br />
session.Close();<br />
con.Close();<br />
|
|
|
|
|
just add
SET NOCOUNT ON
in the procdure
it's a magic.
|
|
|
|
|
I have made a OLE DB Provider using "ATL OLE DB Provider Wizard" in VS 2005.I tried to implement bookmark in it
but it seems consumers can not recognize bookmark bookmark capability of my provider.I have these lines in
property map set of my rowset object:
PROPERTY_INFO_ENTRY_EX(BOOKMARKS, VT_BOOL, DBPROPFLAGS_ROWSET | DBPROPFLAGS_READ | DBPROPFLAGS_WRITE , VARIANT_TRUE, 0)
PROPERTY_INFO_ENTRY_EX(BOOKMARKSKIPPED,VT_BOOL, DBPROPFLAGS_ROWSET | DBPROPFLAGS_READ, VARIANT_TRUE, 0)
PROPERTY_INFO_ENTRY_EX(BOOKMARKTYPE, VT_I4, DBPROPFLAGS_ROWSET | DBPROPFLAGS_READ, DBPROPVAL_BMK_NUMERIC, 0)
PROPERTY_INFO_ENTRY_EX(LITERALBOOKMARKS, VT_BOOL, DBPROPFLAGS_ROWSET | DBPROPFLAGS_READ | DBPROPFLAGS_WRITE, VARIANT_TRUE, 0)
PROPERTY_INFO_ENTRY_EX(ORDEREDBOOKMARKS, VT_BOOL, DBPROPFLAGS_ROWSET | DBPROPFLAGS_READ | DBPROPFLAGS_WRITE, VARIANT_TRUE, 0)
and even my data source tables don't have bookmark column,I put an extra column(with ordinal=0) as the first
column of rowset object which is created in Execute method of this object.
But in session object,IRowsetSchema interface only returns the tables columns not included any entry for Bookmark.
should I include a column entry for Bookmark in column schema of any table?
should I always include bookmark column in returning data rowsets or it depends on consumer request?
Is there any sample code which shows implementing bookmark inside the "Execute" method of rowset object?
May you answer these questions please?
Thanks in advance
|
|
|
|
|
Hi friends,
My product have a ATL/COM based C++ service (32 bit). It get registered and run fine on XP 32 bit and Vista 32 bit.
But now I want to run the same on Windows7 64 bit also. I tried to register the service the following way:
1 I did Copy MyService.exe at C:\Windows\SysWOW64.
2 Then executing "C:\Windows\SysWOW64\MyService.exe" -RegServer from Start->Run
3 Then executing "C:\Windows\SysWOW64\MyService.exe" -Service from Start->Run
But my service is not getting registered. While registering it, I don't get any error message. Also I didn't find any entry in event viewer (I saw event viewer first time. Don't know where to see the log about registration of my service). And I didn't find entry for my service at Control Panel\Administrative Tools\Services.
Please advise me how can I register my service?
Thanks in Advance
Regards
|
|
|
|
|
Did you install your service first? How was your service is installed in XP 32?
Service is installed with CreateSerice() API. Check out how this was handled in XP 32 case.
You can have your own logs during CreateService() API and see what went wrong in Win7 x64.
I am not sure why you need to copy the MyService.exe in SysWow64 folder.
Your service Dll\EXE can be anywhere.
-Prashanth Jaligama
|
|
|
|
|
Hi Prashanth,
Thanks for replying me. Finally I got the answer for my query. To run a command in Start->RUN (on Windows7 or Vista) with escalated rights we should press Ctrl+Shift+Enter. It will then run the command with admin rights. Earlier since I was pressing Enter only, service was not getting registered.
About placing the service in SysWow64, since all my binaries are in SysWow64, I am placing the service's exe there only.
Regards
Aseem
|
|
|
|
|
HI Aseem,
Good to know that you solved your issue.
alternatively you can elevate run prompt from Task Manager.
Go to TaskManager
click on Processes Tab
Click on Show process from All users
Go to File Menu->New Task
This allows the execute command in admin mode.
Thanks
Prashanth
|
|
|
|
|
when i complier these codes, the warning will come :
static void err_doit(int errnoflag, int level, const char* fmt, va_list ap)
{
int errno_save, n;
char buf[MAXLINE+1];
errno_save = errno;
#ifdef HAVE_VSNPRINTF
vsnprintf(buf, MAXLINE, fmt, ap);
#else
vsprintf(buf, fmt, ap);
#endif
n = strlen(buf);
if(errnoflag)
snprintf((char*)(buf+n), MAXLINE-n, ";%s", strerror(errno_save));
strcat(buf, "\n");
if(daemon_proc)
{
syslog(level, (const char*)buf);
}
else
{
fflush(stdout);
fputs(buf, stderr);
fflush(stderr);
}
return;
}
</pre>
the warnning is:
In file included from str_cli.c:2,
from tcpcli01.c:2:
error.c: In function ‘void err_doit(int, int, const char*, char*)’:
error.c:98: warning: format not a string literal and no format arguments
i this warning, for i don't make buf to (const char*), but i try, it don't work.
please give me some advices, thank you
|
|
|
|
|
The specification for syslog() is
void syslog(int priority, const char *format, ...);
and your call uses buf as the format parameter, but its content does not contain any format control characters, and your call does not include any parameters. If you rewrite it as
syslog(level, "%s", buf);
it should work OK.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I do an example to emulate keyboard with SendInput. Here is the code to press "a" with "dwFlags = KEYEVENTF_UNICODE".
Code:
INPUT inp[2];
memset(inp,0,2*sizeof(INPUT));
inp[0].type = INPUT_KEYBOARD;
inp[0].ki.dwFlags = KEYEVENTF_UNICODE ;
inp[0].ki.wScan = "a";
inp[1] = inp[0];
inp[1].ki.dwFlags |= KEYEVENTF_KEYUP;
SendInput(2, inp, sizeof(INPUT)); // Press "a"
Do you know how to press "a" with dwFlags = 0 and ki.wVk = "virtual key of a" ?
Thanks and regards.
|
|
|
|
|
Hi all,
I am developing a project like abode reader, I have a problem:
I need to display the ".pdf" file in the full screen model, and I have no idea to implement it.
Did anyone do it or could you tell me the main idea?
Thanks in advance.
|
|
|
|
|
Do you want to implement another PDF reader from scratch? or do you want to use Acrobat to show a PDF in full screen?
--
Si dos montan un caballo, uno debe ir detrás.
|
|
|
|
|
Yeah, I'm making my own application to implement adboe reader, now I need some thought how to
complete the full screen model.
|
|
|
|
|
See here[^] for the options to resize your window.
However, if you are saying that you have no idea how to write a PDF reader then I suggest you do some research into the PDF libraries that are available. There may also be some articles here on CodeProject that show you the basics.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Thank you, guys. I am making my own pdf reader, if you have some links to resource or source code, I should really thank you! 
|
|
|
|
|
Did you read my answer? I have given you some suggestions how to find free libraries to handle PDF files. You can also get the full PDF specification from the Adobe web site and code the whole thing yourself.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|