|
Hello,
Please have a look at the code ,I can't realise the funcation.Thank you very much !
----------------------------------------------
BOOL CMultiProgressDlg::OnInitDialog()
{
.......................
hDownLoaderDlgWnd = this->m_hWnd;
...........................
}
void ShowProgress(LPVOID lpProgress)
{
CProgressCtrl *bpm_COMM= (CProgressCtrl*) GetDlgItem(hFlashDownLoaderDlgWnd,* (int*)lpProgress);
for(int i = 0; i< 100; i++)
{
bpm_COMM->SetPos(i);
Sleep(100);
}
}
void CMultiProgressDlg::OnOK()
{
// TODO: Add extra validation here
HANDLE hThrds[3];
DWORD dwThreadId[3] ;
UINT ProgressnID[3] = { IDC_PROGRESS1,IDC_PROGRESS2,IDC_PROGRESS3 } ;
for(int i = 0; i < 3; i++)
{
hThrds[i] =CreateThread(
NULL,//LPSECURITY_ATTRIBUTES lpThreadAttributes, // pointer to security attributes
0, //DWORD dwStackSize, // initial thread stack size
(LPTHREAD_START_ROUTINE)ShowProgress,// LPTHREAD_START_ROUTINE lpStartAddress,
&ProgressnID[i],
0, //DWORD dwCreationFlags,
&dwThreadId[i]);//LPDWORD lpThreadId
}
}
|
|
|
|
|
It would help if you i)formatted your code properly so it is clear and easy to read, and ii)explained exactly what your problem is.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
You want to show 3 simultaneous progress bars? What's the process that will be updating them? ...You should not access any dialog items directly from an independent thread like that, instead, send a message to the dialog via PostMessage() telling it to update whatever progress bar you want to update. Within your dialog class, have a message handler that updates the progress bar accordingly.
|
|
|
|
|
Hi,
I need to retrive a list from IP server.
Do you know how to do it by AsyncIO?
Thanks!
|
|
|
|
|
I think you would need to do it by using a socket connection or HTTP feed.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
You can use bosst asio.
And as you are looking to retrive any collection object, I would propose you to use boost serialization, it is more easier to code and design these kind of requirement.
|
|
|
|
|
Hi,
I have following MPI code
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ARRAYSIZE 2000
#define MASTER 0
int data[ARRAYSIZE];
int main(int argc, char* argv[])
{
int numtasks, taskid, rc, dest, offset, i, j, tag1, tag2, source, chunksize, namelen;
int mysum;
long sum;
int update(int myoffset, int chunk, int myid);
char myname[MPI_MAX_PROCESSOR_NAME];
MPI_Status status;
double start = 0.0, stop = 0.0, time = 0.0;
double totaltime;
FILE *fp;
char line[128];
char element;
int n;
int k=0;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numtasks);
MPI_Comm_rank(MPI_COMM_WORLD,&taskid);
MPI_Get_processor_name(myname, &namelen);
printf ("MPI task %d has started on host %s...\n", taskid, myname);
chunksize = (ARRAYSIZE / numtasks);
tag2 = 1;
tag1 = 2;
if (taskid == MASTER){
fp=fopen("integers.txt", "r");
if(fp != NULL){
sum = 0;
while(fgets(line, sizeof line, fp)!= NULL){
fscanf(fp,"%d",&data[k]);
sum = sum + data[k];
k++;
}
}
printf("Initialized array sum %d", sum);
offset = chunksize;
for (dest=1; dest<numtasks; dest++) {
MPI_Send(&offset, 1, MPI_INT, dest, tag1, MPI_COMM_WORLD);
MPI_Send(&data[offset], chunksize, MPI_INT, dest, tag2, MPI_COMM_WORLD);
printf("Sent %d elements to task %d offset= %d\n",chunksize,dest,offset);
offset = offset + chunksize;
}
offset = 0;
mysum = run_kernel(&data[offset], chunksize);
printf("Kernel returns sum %d", mysum);
for (i=1; i<numtasks; i++) {
source = i;
MPI_Recv(&offset, 1, MPI_INT, source, tag1, MPI_COMM_WORLD, &status);
MPI_Recv(&data[offset], chunksize, MPI_INT, source, tag2,MPI_COMM_WORLD, &status);
}
MPI_Reduce(&mysum, &sum, 1, MPI_INT, MPI_SUM, MASTER, MPI_COMM_WORLD);
printf("\n*** Final sum= %d ***\n",sum);
}
if (taskid > MASTER) {
start= MPI_Wtime();
source = MASTER;
MPI_Recv(&offset, 1, MPI_INT, source, tag1, MPI_COMM_WORLD, &status);
MPI_Recv(&data[offset], chunksize, MPI_INT, source, tag2,MPI_COMM_WORLD, &status);
mysum = run_kernel(&data[offset], chunksize);
printf("\nKernel returns sum %d ", mysum);
stop = MPI_Wtime();
time = stop -start;
printf("time taken by process %d to recieve elements and caluclate own sum is = %lf seconds \n", taskid, time);
dest = MASTER;
MPI_Send(&offset, 1, MPI_INT, dest, tag1, MPI_COMM_WORLD);
MPI_Send(&data[offset], chunksize, MPI_INT, MASTER, tag2, MPI_COMM_WORLD);
MPI_Reduce(&mysum, &sum, 1, MPI_INT, MPI_SUM, MASTER, MPI_COMM_WORLD);
}
MPI_Finalize();
}
int update(int myoffset, int chunk, int myid) {
int i,j;
int mysum = 0;
for(i=myoffset; i < myoffset + chunk; i++) {
mysum = mysum + data[i];
}
printf("Task %d has sum = %d\n",myid,mysum);
return(mysum);
}
and I have following cuda code
#include <stdio.h>
__global__ void add(int *devarray, int *devsum)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
devsum = devsum + devarray[index];
}
extern "C"
int * run_kernel(int array[],int nelements)
{
int *devarray, *sum, *devsum;
printf("\nrun_kernel called..............");
cudaMalloc((void**) &devarray, sizeof(int)*nelements);
cudaMalloc((void**) &devsum, sizeof(int));
cudaMemcpy(devarray, array, sizeof(int)*nelements, cudaMemcpyHostToDevice);
add<<<2, 3>>>(devarray, devsum);
cudaMemcpy(sum, devsum, sizeof(int), cudaMemcpyDeviceToHost);
printf(" \nthe sum is %d", sum);
cudaFree(devarray);
return sum;
}
I am getting following output
Here is my output when I run above code -
MPI task 0 has started on host
MPI task 1 has started on host
MPI task 2 has started on host
MPI task 3 has started on host
Initialized array sum 9061Sent 500 elements to task 1 offset= 500
Sent 500 elements to task 2 offset= 1000
Sent 500 elements to task 3 offset= 1500
[node4] *** Process received signal ***
run_kernel called..............
[node4:04786] Signal: Segmentation fault (11)
[node4:04786] Signal code: Invalid permissions (2)
[node4:04786] Failing at address: 0x8049828
[node4:04786] [ 0] [0xaf440c]
[node4:04786] [ 1] /usr/lib/libcuda.so(+0x13a0f6) [0xfa10f6]
[node4:04786] [ 2] /usr/lib/libcuda.so(+0x146912) [0xfad912]
[node4:04786] [ 3] /usr/lib/libcuda.so(+0x148094) [0xfaf094]
[node4:04786] [ 4] /usr/lib/libcuda.so(+0x13ca50) [0xfa3a50]
[node4:04786] [ 5] /usr/lib/libcuda.so(+0x11863c) [0xf7f63c]
[node4:04786] [ 6] /usr/lib/libcuda.so(+0x11d167) [0xf84167]
[node4:04786] [ 7] /usr/lib/libcuda.so(cuMemcpyDtoH_v2+0x64) [0xf74014]
[node4:04786] [ 8] /usr/local/cuda/lib/libcudart.so.4(+0x2037b) [0xcbe37b]
[node4:04786] [ 9] /usr/local/cuda/lib/libcudart.so.4(cudaMemcpy+0x230) [0xcf1360]
[node4:04786] [10] mpi_array(run_kernel+0x135) [0x8049559]
[node4:04786] [11] mpi_array(main+0x2f2) [0x8049046]
[node4:04786] [12] /lib/libc.so.6(__libc_start_main+0xe6) [0x2fece6]
[node4:04786] [13] mpi_array() [0x8048cc1]
[node4:04786] *** End of error message ***
Kernel returns sum 134530992 time taken by process 1 to recieve elements and caluclate own sum is = 0.276339 seconds
run_kernel called..............
devsum is 3211264
the sum is 134532992
Kernel returns sum 134532992 time taken by process 2 to recieve elements and caluclate own sum is = 0.280452 seconds
run_kernel called..............
devsum is 3211264
the sum is 134534992
Kernel returns sum 134534992 time taken by process 3 to recieve elements and caluclate own sum is = 0.285010 seconds
------------------------------------------------------------- -------------
mpirun noticed that process rank 0 with PID 4786 on node ecm-c-l-207-004.uniwa.uwa.edu.au exited on signal 11 (Segmentation fault).
Perhaps the sum does not look correct. Not sure what is causing segmentation fault. Can anyone help?
Thanks
|
|
|
|
|
Hi,
I am trying to run following code which contains OpenMPI and CUDA.
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <sys/time.h>
#include <mpi.h>
#define NREPEAT 10
#define NBYTES 10.e6
int main (int argc, char *argv[])
{
int rank, size, n, len, numbytes;
void *a_h, *a_d;
struct timeval time[2];
double bandwidth;
char name[MPI_MAX_PROCESSOR_NAME];
MPI_Status status;
MPI_Init (&argc, &argv);
MPI_Comm_rank (MPI_COMM_WORLD, &rank);
MPI_Comm_size (MPI_COMM_WORLD, &size);
MPI_Get_processor_name(name, &len);
printf("Process %d is on %s\n", rank, name);
printf("Using regular memory \n");
a_h = malloc(NBYTES);
cudaMalloc( (void **) &a_d, NBYTES);
MPI_Barrier(MPI_COMM_WORLD);
gettimeofday(&time[0], NULL);
for (n=0; n<NREPEAT; n )
{
cudaMemcpy(a_d, a_h, NBYTES, cudaMemcpyHostToDevice);
}
gettimeofday(&time[1], NULL);
bandwidth = time[1].tv_sec - time[0].tv_sec;
bandwidth = 1.e-6*(time[1].tv_usec - time[0].tv_usec);
bandwidth = NBYTES*NREPEAT/1.e6/bandwidth;
printf("Host->device bandwidth for process %d: %f MB/sec\n",rank,bandwidth);
MPI_Barrier(MPI_COMM_WORLD);
gettimeofday(&time[0], NULL);
for (n=0; n<NREPEAT; n )
{
if (rank == 0)
MPI_Send(a_h, NBYTES/sizeof(int), MPI_INT, 1, 0, MPI_COMM_WORLD);
else
MPI_Recv(a_h, NBYTES/sizeof(int), MPI_INT, 0, 0, MPI_COMM_WORLD, &status);
}
gettimeofday(&time[1], NULL);
bandwidth = time[1].tv_sec - time[0].tv_sec;
bandwidth = 1.e-6*(time[1].tv_usec - time[0].tv_usec);
bandwidth = NBYTES*NREPEAT/1.e6/bandwidth;
if (rank == 0)
printf("MPI send/recv bandwidth: %f MB/sec\n", bandwidth);
cudaFree(a_d);
free(a_h);
MPI_Finalize();
return 0;
}
To compile I am using :
mpicc mpibandwidth.c -o mpibandwidth -I /usr/local/cuda/include -L /usr/local/cuda/lib -lcudart
To execute I am using :
/usr/local/bin/mpirun --mca btl tcp,self --mca btl_tcp_if_include eth0 --hostfile slaves -np 5 mpibandwidth
I am getting error after executing :
error while loading shared libraries: libcudart.so.4: cannot open shared object file: No such file or directory
My PATH and LD_LIBRARY_PATH variables are:
PATH = /usr/lib/qt-3.3/bin:/usr/local/ns-allinone/bin:/usr/local/ns- allinone/tcl8.4.18/unix:/usr/local/ns-allinone/tk8.4.18/unix:/ usr/local/cuda/cuda/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/ sbin:/usr/sbin:/sbin:/usr/local/lib/:/usr/local/lib/openmpi:/usr/ local/cuda/bin
LD_LIBRARY_PATH = :/usr/local/lib:/usr/local/lib/openmpi/:/usr/local/cuda/lib
:/usr/local/lib:/usr/local/lib/openmpi/:/usr/local/cuda/lib
libcudart.so.4 is present in usr/local/cuda/lib and it is in LD path
Any idea what is missing?
Can someone help please
Thanks
|
|
|
|
|
If you are certain that the file exists in the library pointed to then the issue must rest with the mpirun command. Are you sure that it uses LD_LIBRARY_PATH to locate its libraries?
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
Yes I am pretty sure that mpirun uses correct libraries. I have several other openmpi program which work fine on cluster. Only this one, mixture of mpi and cuda doesnt work.
All the libraries do exist in pointed directories. and LD paths mentioned above are correct.
I have tried running the program only using master node and it works fine. But when I include slave nodes it gives error mentioned in original post.
All the slaves have same installation with correct LD paths
Not sure why its not working
|
|
|
|
|
Ron1202 wrote: Not sure why its not working
Sorry, nor me. I can only suggest you look inside the program and see if you can add any debug code that may help to diagnose it.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
I'v implemented an IE browser in my application base on CHtmlView, the "back" and "forward" functon are always avaliable, but I want to make the "back" button disabled when the current page point to the first position of the history list, and make the "forward" button disabled when the current page point to the last position of the history list.
I can't find the method to the history list, so that I can't implemented the function, is there anyone can inform me how to do it? thanks very much!
|
|
|
|
|
You will need to keep track of this yourself.
When the back and forward buttons are pressed, you can decrement and increment a counter respectively.
When navigating to a new page increment the counter after the OnDocumentComplete event is trigerred.
|
|
|
|
|
Hey Guys,
My requirement is like this - I need to take ownership of some directory and delete it.
I used this sample as it is but it fails to give me the ownership in the following scenario.
#Case:
I create a limited access user say "Limited_User". I created a directory (ownership of the directory will now be with Limited_User) and I set the all the Administrator rights as Denied. Now, from my administrator user, if I am trying to take the ownership again, the function sets its privilege but setting the ownership fails with ERROR_ACCESS_DENIED. This problem is reproducible on XP / 7.
Please help me with this guys.... Thanks a lot in advance...
--
Varun
|
|
|
|
|
Hi, I am writing a driver for windows XP and above OS.
But i got stuck in swprintf_s , In Windows 7 it works nicely, but in windows xp, Procedure is not found .
swprintf works in windows xp, but the ddk warns about swprintf , that it is banned.
I am using Windows 7 DDK.
please suggest some work-around in this condition.
Regards,
Vishal
|
|
|
|
|
vishalgpt wrote: please suggest some work-around in this condition.
Not all the CRT functions are available at driver level so you need to check the DDK documentation for compatible functions. Many of the DDK functions have the prefix Rtl and are described here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
hi,
i'm curious if it's possible to find out ControlID of component under which was mouse pressed... of course i'd like to find it inside mouse hook.
LRESULT CALLBACK WinHookRunner::OnMouseEvent(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode == HC_ACTION) {
MSLLHOOKSTRUCT* pData = (MSLLHOOKSTRUCT*)lParam;
if(wParam == WM_LBUTTONDOWN){
qDebug("MOUSE: "+QString::number(pData->pt.x).toAscii()+":"+QString::number(pData->pt.y).toAscii()+" :: "+ QString::number(pData->dwExtraInfo).toAscii());
}
}
return CallNextHookEx(m_hMouseHook, nCode, wParam, lParam);
|
|
|
|
|
The MSLLHOOKSTRUCT structure has pt member which indicates the point at which the mouse was clicked.
Use this in a call to the WindowFromPoint API to get the handle of the control.
Then use this handle in a call to the GetDlgCtrlID function.
|
|
|
|
|
thanks a lot... exactly what i need!
|
|
|
|
|
i'm trying to change the keyboard layout from my program. it loads the new keyboard but doesn't activates it to the new layout.
here's my code:
please help me. i've to submit it asap.
#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <conio.h>
using namespace std;
class _KeyboardLayout
{
public:
HKL hBengali;
bool bBengali;
HKL hEnglish;
bool bEnglish;
_KeyboardLayout();
} ;
_KeyboardLayout::_KeyboardLayout()
{
bBengali=false;
bEnglish=false;
}
int main()
{
_KeyboardLayout KeyboardLayout;
TCHAR szKeyboard[KL_NAMELENGTH];
int nBuff=::GetKeyboardLayoutList(0, NULL);
int nKeyboard;
HKL * phkl;
if((phkl = new HKL[nBuff])==NULL)
{
cout<<"Out of Memory !";
return 1;
}
int x=::GetKeyboardLayoutList(nBuff,phkl);
for(nKeyboard=0; nKeyboard<nBuff; nKeyboard++)
{
::ActivateKeyboardLayout(phkl[nKeyboard], KLF_SETFORPROCESS);
GetKeyboardLayoutName(szKeyboard);
if(wcscmp(szKeyboard,_T("00000445"))==0)
{
KeyboardLayout.bBengali=true;
KeyboardLayout.hBengali=phkl[nKeyboard];
cout<<phkl[nKeyboard];
}
if(wcscmp(szKeyboard,_T("00000409"))==0)
{
KeyboardLayout.bEnglish=true;
KeyboardLayout.hEnglish=phkl[nKeyboard];
}
}
delete [] phkl;
if(!KeyboardLayout.bBengali)
cout<<"error in bengali layout";
if(!KeyboardLayout.bEnglish)
MessageBox(NULL,_T("English (USA) keyboard layout not installed"),_T("Warning"),MB_OK|MB_ICONEXCLAMATION);
else
{}
cout<<endl<<::LoadKeyboardLayoutW(_T("00000445"),KLF_ACTIVATE | KLF_SETFORPROCESS);
if(KeyboardLayout.bBengali)
{
cout<<endl<<::ActivateKeyboardLayout(HKL(HKL_PREV), KLF_REORDER);}
return 0;
}
|
|
|
|
|
Hi there,
I am using a CAxWindow to implement an IWebBrowser2 control on an ATL Dialog. What I want to do is to display a facebook like button on my dialog.
As this is done via an HTML link, I embed the Webbrowser control into my dialog:
CAxWindow ieWindow = GetDlgItem(IDC_BROWSER_CONTROL);
ieWindow.QueryControl( & m_WebBrowserPointer );
if (m_WebBrowserPointer)
{
VARIANT v;
VariantInit(&v);
std::wstring link = L"http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com&send=false&layout=button_count&width=320&show_faces=false&action=like&colorscheme=light&font&height=21";
HRESULT res = m_WebBrowserPointer->Navigate(CComBSTR(url.c_str()), &v, &v, &v, &v);
}
This works fine so far. The "like"-button appears in my dialog. The problem begins when I click on the button and am not logged in to facebook.
Then, a login dialog appears (a new IE window). When I enter my login data without checking "Keep me logged in", the browser window closes and another browser window with the same content as before appears and I must enter the login data again. This happens 4 times, then the box at "Keep me logged in" is checked automatically, and the login works and my "like"-button changes its look (greyed out).
The login also works properly if I check the mark by hand.
So the problem is: Why does the login dialog appear several times after I have logged in? When I open the link in a standard browser window, the first try works correctly.
Do I have to submit other parameters to the call of Navigate()?
I also tried Fiddler to determine differences between the HTTP requests, but I couldn't figure out the differences. There seems to be a .js-script which loads the page again.
Please tell me if you need any more information. Thanks for your help!
Regards,
Fabian
|
|
|
|
|
Are there any other possibilities to show a browser window in an ATL dialog?
|
|
|
|
|
I have a COM dll used by an other application (release) on Windows 7 64bit.
The Debug version of dll COM works fine.
But the release version causes crash.
When trying to get the origin of problem (with "try...catch" )I discovered that it seems to be in the instruction below :
m_pConnection->Open(bstrConnectionString, wstrSuperUserDB.c_str(), wstrSACUserPassword.c_str(), Internal::adConnectUnspecified);
where :
m_pConnection : Internal::_ConnectionPtr
bstrConnectionString : _bstr_t
wstrSuperUserDB, wstrSACUserPassword : std::wstring
please have you any idea about this ?
|
|
|
|
|
compile the release version with no optimisations, enable debug code in the compiler and linker, then debug it
|
|
|
|
|
sorry for the mistake
I mean that the dll installed with the Installer causes crash.
but the dll I just compile (debug or release version) works well.
I think the problem is at this level (i'm not sure):
m_pConnection->Open(bstrConnectionString, wstrSuperUserDB.c_str(), wstrSACUserPassword.c_str(), Internal::adConnectUnspecified);
(this is using a log file)
Is this related to the creation of version installer or something else ?!
|
|
|
|
|