Quantcast
Channel: CodeProject Latest postings for C / C++ / MFC
Viewing all 3781 articles
Browse latest View live

Is it possible to get Vb control information (properties) using .Net remoting

$
0
0
Hi Everyone,

we are developing a simple testing tool for GUI testing using AutomationElement (AE). We want extend it to support VB controls also.
But we can not VB control information using AE. I want use .Net remoting to VB control information. Is it possible?

Regards,
Rajendar.

Activating a Window

$
0
0
Hi!
I ran the Activating a Window program and found that it goes in an endless loop, where one of the three states it can switch to will be selected, however none of the close buttons on the message boxes function and the only way I was able to end the program was by use of the Task Manage. I have tried a variety of solutions, but none are worthy. I also notice that even when I use my mouse to react to the message boxes, the message that comes up can be This window has been activated, without the mouse.
This seems pretty dysfunctional in terms of a tool to switch between window, since a method should be possible by which to deactivate and close all the windows shown.

Psola python implementation

$
0
0
Hello there, sorry but am a noob at this..... My question is: is there a python implementation of psola

VC++ 2013 Ultimate IDE is very slow

$
0
0
Hello there. VC++ part of the visual studio is very slow. Debugging is very slow, choosing and compiling a project is very slow, typing is very slow (sometimes it takes more than one second for a letter to show after its corresponding key was hit).

Why is there so much delay in text editor and other things? (Rest of the visual studio i.e. C# and VB are fine). What could be wrong ??

This world is going to explode due to international politics, SOON.

how to use d following sha1 zip file

$
0
0
www.codeproject.com/KB/recipes/csha1/CSHA1-2.1-Source.zip
i downloaded d sha1(a hash algo) code from d given link,but i don't know how to use this zip file to encrypt my msg.
pls help!

Assigning data to int array using pointers

$
0
0
I am trying to rebuild small data base to improve on my terrible knowledge of pointers.
The array is pretty simple integers representing ASCII code , I do the conversion by casting the int or char to LCD print function for display. Works fine with one problem - one of the int in the array is a REAL number ( 0 thru 9)   , not just ASCII representation of a number.
For illustration - the ints are 32 65 73 7 73

The "problem " the index #3 does not read just 7 , but 773.
And the array sizeof is also 3 , and it should be 4.

Majority of the code is just for debug.

I can change the real numbers to ASCII representation but would like to know why is this behaving this way.
Appreciate your help.
Vaclav

<pre><pre  
      int *pCarrier[sizeof(iRecordIndex)];           
            for (i = 0; i != sizeof(iRecordIndex); i++)
            {
               pCarrier[i] = &iRecord[i];         // assign data to pointer
               lcd_i2c.setCursor(0, 0);
               lcd_i2c.print("Index " );
               lcd_i2c.print(i);
               lcd_i2c.setCursor(0, 1);
               lcd_i2c.print((char) iRecord[i] );
               lcd_i2c.setCursor(0, 2);
               lcd_i2c.print(iRecord[i] );
               lcd_i2c.print(" ");

               lcd_i2c.print(*pCarrier[i] );
               delay(DELAY);
            }
           

            lcd_i2c.clear();
            lcd_i2c.print("Database   " );
            lcd_i2c.setCursor(0, 1);
            for (i = 0; i !=   sizeof(iRecordIndex)+ 1 ; i++)
            {
               lcd_i2c.print((int)*pCarrier[i] );
               delay(DELAY);
            }

pre></pre>

Reading uncompressed AVI file frame by frame into raw memory buffer?

$
0
0
As the title states, I am having problems reading uncompressed avi files in MFC. It works fine on some files and reads different data on some avi files.

Here is the code-
pStream = g_GetAviStream(_T("D:\\Lab_Programs\\Matlab\\output.avi"), &frames, &fWidth, &fHeight, &iFirstFrame, &nPlanes, &fBufSize);
fWidthOffs = fWidth%4;
tempBuff = new BYTE[fWidth*fHeight*nPlanes];
ZeroMemory(tempBuff, sizeof(BYTE)*fWidth*fHeight*nPlanes);
 
pFrame = AVIStreamGetFrameOpen(pStream, NULL);
 
bytBuff   = new BYTE[fBufSize];//fWidth*fHeight*nPlanes];
// read video stream to video buffer
for (i = 0; i < frames; i ++)
{
	// the returned is a packed DIB frame
	imgTemp = (BYTE*) AVIStreamGetFrame(pFrame, i);
 
	RtlMoveMemory(&bih.biSize, imgTemp, sizeof(BITMAPINFOHEADER));
 
	//now get the bitmap bits and get rid of the header information and retrieve the real image 
	RtlMoveMemory(bytBuff, imgTemp+sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)*256, bih.biSizeImage);
	ind = i*fWidth*fHeight*nPlanes;
	for (j = 0; j < fHeight; j ++) {	
		idxd1 = j*nStimVideoNX;
		idxs = (fHeight-1-j) * (fWidth * nPlanes + fWidthOffs);
		for (k = 0; k < fWidth/*nStimVideoNX*/; k ++) {
	datain = bytBuff[idxs + k*nPlanes];
	tempBuff[idxd1+k] = datain;
							
		}
	}
}
			

After doing this, I am writing tempBuff to a text file to view the contents in maltab and imshow it. If you play the video, you will see two black squares inside the frame, but when I check the text file for frame 3, I only see one black square. Here is the link[^] for a sample file that I am trying to read.
PKNT

C or C++ for customized embedded Linux, which is the best and why?

$
0
0
I aim to build a network system like router or firewall based on customized embedded Linux. about the memory and stack, I will use embedded appliance like ARM boards or Atom not a simple Micro-controller or processor. which lang. you advice me to use C or C++? . I will use YOCTO Project to help me do that, so any advice?
I built a similar network system.it was a network IDS but, it was based on xPC Target Kernel. Now, I wish to use an Embedded Linux. the system must do the basic task, so no many options. I have an experience in C and C++ but under DOS not Linux. C++ has the many options make the system design is easier but I fare the compatibility if I used it in embedded Linux. So any advice?

C or C++ for customized embedded Linux, which is the best and why?

$
0
0
I aim to build a network system like router or firewall based on customized embedded Linux. about the memory and stack, I will use embedded appliance like ARM boards or Atom not a simple Micro-controller or processor. which lang. you advice me to use C or C++? . I will use YOCTO Project to help me do that.
I built a similar network system.it was a network IDS but, it was based on xPC Target Kernel. Now, I wish to use an Embedded Linux. the system must do the basic task, so no many options. I have an experience in C and C++ but under DOS not Linux. C++ has the many options make the system design is easier but I fare the compatibility if I used it in embedded Linux. So any advice?

Add button to vertical toolbar embedded in CPagerCtrl embedded in CDockingPane attached to CFrameWndEx

$
0
0
Hello everyone,

I have a weird situation...I have a CToolBar that has a parent of a CPagerCtrl which has a parent of a CDockingPane. Why I developed it that was is a long story and changing the architecture is not really an option at this point. Everything is working quite well except for one problem behavior. And this wouldn't have been a problem had the requirements not changed.

The problem behavior is that initially the toolbar has 9 buttons, but before it is shown I remove some of them depending on the options enabled. Depending on the state of the application at a particular time I may add buttons back. The toolbar does not reflect the change. In the past I would have just called RecalcLayout() on the frame window and voila, the toolbar would adjust it's size to properly reflect the new buttons.

I am at a loss on how to accomplish this with this architecture. I have tried many things...so many I can't remember them right now. Any ideas/help would be greatly appreciated. I will post any code upon request. I am just not sure what is of value right now.

Thanks,

Craig

Accessing / printing two dimensional array of char using pointers

$
0
0
I am still struggling with pointers arithmetic.
Here is my crude test code.
I want to use pointers to access ( double - need triple eventually) the array of characters and do not get two things.

Problem #1 is probably how does the LCD class do the "print" and I can figure that one by myself. I do not expect this forum to be familiar with Arduino "library".

Problem # 2
I can print single characters in simple array by incrementing the pointer, but I cannot figure out why I cannot use same method on double array.
I really do not understand what is this error telling me
"error lvalue required as increment operand" - what is "lvalue" ?

Please keep in mind that English is not my native language so go easy on
" pointers to array..." "array of pointers" etc.

As always , I appreciate your help.
Cheers
Vaclav


Addendum
OK, I did some more reading about how the array is initialized and how the NAME of the array cannot be used the way I did try it.

So I did this - it "works" , but I am still not sure if it is correct or just a fluke.


   char   *pointer = stringTable[0];
   lcd_i2c.print((char*) pointer++); // prints entire line
   lcd_i2c.print((char*) pointer); // prints entire line starting with second character - expected that




Original post code starts here
char line[MAX_LINE] = "A TEST B";
   int ncharacters = strlen(line);

char *sptr;               // pointer to memory block returned by malloc
   char *stringTable[NLINES];   // array of pointers to string
   int i = 0;
   sptr = (char*) malloc((unsigned) strlen(line) + 1);


   lcd_i2c.clear();
   lcd_i2c.print("Index ");
   lcd_i2c.print(i);
   lcd_i2c.setCursor(0, 1);

   lcd_i2c.print("Length   ");
   lcd_i2c.print(ncharacters );

   lcd_i2c.setCursor(0, 2);
   lcd_i2c.print("pointer   ");
   lcd_i2c.print(sptr);                     // problem #1 prints the entire line - not really a problem here


   strcpy(sptr, line);                     // copy line to pointed memory
   lcd_i2c.print(sptr); // TOK prints pointer value ?  
   // copy pointer to first table array
   stringTable[0] = sptr;
   lcd_i2c.setCursor(0, 3);
   i = 0;
   do
   {
      // TOK prints first character from stringTable[0]
      lcd_i2c.print((char) * (*stringTable));   // problem #1 prints only the first character - why it would be nice to print the entire line using pointers!

   } while (*(*++stringTable));   error lvalue required as increment operand

Error reading characters of string

$
0
0
Hello there. I have this structure in Header1.h and instantiating this structure in Header2.h. When I try to initialize this instance, I get this runtime exception. Here is my skeleton of code
HEADER1.h 
struct Student {
    CString Name;
    CString Address;
    CString Phone;
};
 
HEADER2.h 
class CHeader2Dlg {
    //.....
    Student student;
    //.....
}
 
HEADER2.cppvoid CHeader2Dlg::SomeFunction()
{
    student.Name = ""; // Here I am getting the said exception
    student.Address = "";
    student.Phone = "";
 
}

Who has the type of remote control code, can you give me a copy?

C++ Service Crash in Windows Server 2008 R2 Machine

$
0
0
Hi All,


While running a C++ Service in Wice indows 2008 Server i got below dump for service crash.


Crash Dump
------------

00 ntdll!ZwWaitForMultipleObjects+0xa
01 ntdll!RtlReportException+0x55e
02 ntdll!RtlReportException+0xbc
03 ntdll!RtlpNtMakeTemporaryKey+0x216
04 ntdll!_C_specific_handler+0x96
05 ntdll!wcstok_s+0x34be
06 ntdll!_chkstk+0x9d
07 ntdll!RtlRaiseException+0xf67
08 ntdll!RtlRaiseException+0x18d
09 ntdll!RtlpNtMakeTemporaryKey+0x1c0
0a ntdll!RtlpNtMakeTemporaryKey+0x3402
0b ntdll!RtlpNtMakeTemporaryKey+0x4000
0c ntdll!memset+0x160da
0d msvcr110!free+0x1c
0e wincli32!ConnectDlg+0x392
0f wincli32!OsGetCOPCLIVersion+0x7fed
10 ntdll!RtlActivateActivationContextUnsafeFast+0x114
11 ntdll!LdrShutdownThread+0x116
12 ntdll!RtlExitUserThread+0x3e
13 kernel32!BaseThreadInitThunk+0x15
14 ntdll!RtlUserThreadStart+0x34


please help me out.

Thanks,
Uday

Passing an "array" in C

$
0
0
Although I use C# most of the time, I try to use C for small exercises -- to keep my C sharp! Unsure | :~

Anyway... I don't recall having to pass arrays back when I was using C full-time (in the 90s), so I don't know which technique is preferred.
As I see it, there are two basic techniques as precedents in C:

0) Passing the length of the array with the array -- e.g. main ( int argc , char *argv[] )
1) Having a "special value" at the end of the array to indicate the end -- e.g. NULL-terminated strings.

So, if I want to pass an array of structs (four ints), which technique is preferred by the C/C++ community?

I'm actually considering door number...

2) Using a linked list instead. It just seems cleaner, though memory usage is actually increased by 25% in this case.

Again, this is just an exercise, but practicing poor technique can be worse than not practicing at all.

So, what say you? If you have to pick door 0 or door 1, which do you prefer?

Efficient way of converting an 8bit array of grayscale pixel data into 24bpp bitmap for GDI+?

$
0
0
Hello,

I have access to array of pixel data (size:512x512x8bpp) from a framegrabber which I currently assign to a 8bpp bitmap which is assigned to a GDI+ graphics object later on.

Now, I would like to convert my array of 8bpp pixel data into 24bpp (BGRA, but I have no use for Alpha channel) and assign it to my bitmap and then modify individual pixel data to different colors depending on other conditions.

When I say efficient, I want it to be done in real-time without much delay.

Any suggestions?

thanks
PKNT

Convert to ASCII ?

$
0
0
This seems very silly and basic -
The function description is pretty clear
Convert an unsigned long integer into a string, using a given base


So why I keep printing numbers and NOT ASCII letter?
I need a pointer to string - not numeric value.

And I am sorry to ask such stupid question.
Cheers
Vaclav


<pre>  
   int base = 10;
   long value = 73;
      char buffer[33];
      unsigned long RANDOM = random(65, 79);
     

      for( base = 2; base <= 16; base = base + 2 ) {
            printf( "%2d %s\n", base,
                  ultoa( RANDOM, buffer, base ) );
      }</pre>

runtime error due to corruption of heap

$
0
0

Hi Guys!,

I'm getting a runtime error, and compiler is pointing at "free.c", shown below:

void__cdecl _free_base (void * pBlock)
{<pre><code>    int retval = 0;if (pBlock == NULL)return;

    RTCCALLBACK(_RTC_Free_hook, (pBlock, 0));
    retval = HeapFree(_crtheap, 0, pBlock);if (retval == 0)
    {
        errno = _get_errno_from_oserr(GetLastError());
    }</code>

}

I couldn't troubleshoot where exactly is the issue..

It would be of great help if you can give some suggestions.. Thanks!

Msbuild for VC++ project having path errors

$
0
0
Hi,
I have build a VC++ dll project that build fine in visual studio environment.
I need to deploy that project to a server, which does not have VS2012, so I wrote a batch file to execute the build tasks using
Msbuild.

Please look at the code below:
@ECHOOFFfor /f "tokens=2*" %%A in ('REG QUERY "HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0" /v MSBuildToolsPath') DO (
    set MSBuildToolsPathVS=%%B)
@ECHO"MSbuildexePath= " %MSBuildToolsPathVS%
set SolFilePath="C:\C++\DllCreateProj\DllCreateProj.vcxproj"@ECHO"SolFilePath= "%SolFilePath%
 
cd %MSBuildToolsPathVS%
msbuild.exe %SolFilePath% /p:configuration=release;Platform=x64

The project build fine,except the following warning:
Quote:
Creating "x64\release\DllCreateproj.unsucessfullbuild" because "alwayscreate" was specified

I had this message before for the same project at different location, so I copied solution, and rebuilt it, and there is no such message in VS IDE but msbuild gives this message

I modify the script to log the results as:
@ECHO OFF
for /f "tokens=2*" %%A in ('REG QUERY "HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0" /v MSBuildToolsPath') DO (
set MSBuildToolsPathVS=%%B)
@ECHO "MSbuildexePath= " %MSBuildToolsPathVS%
set SolFilePath="C:\C++\DllCreateProj\DllCreateSol.sln"
@ECHO "SolFilePath= "%SolFilePath%
set MSBuildLogPath="C:\C++\DllCreateProj\Buildlog.txt"
@ECHO "MSBuildLogPath= "%MSBuildLogPath%
 
cd %MSBuildToolsPathVS%
 
msbuild.exe %SolFilePath% /p:configuration=release;Platform=x64^
 /fileLoggerParameters:LogFile=%MSBuildLogPath%;Verbosity=detailed;
 /t:clean;rebuild

Now, the paths print out correctly and I have verified that.
However, "Buildlog.txt" is not created and also, after the "build Suceeded" message, I get following message twice
Quote:
The filename,directory name ,or volume label syntax is incorrect.


So, I have following questions:
1) How do I solve the warning for "unsucessfulbuild" ?
2) How do I specify path for log file correctly.
3) Why do I get the "volume label incorrect " message, and is there a way to get more information about that?
4) Given path to msbuild that I have extracted, I need to modify "SolFilePath" and "msBuildLogPath" as being relative to ,say release path
Quote:
C:\C++\DllCreateProj\x64\Release
"
Any help with that?

Thanks

strcpy dilemma - it works half way

$
0
0
I am going crazy over this simple test code.

char *Result ={"Result init "};
char *Source = {"123"};
char *Destination  = {"456"};

I can verify that all strings are as initialized.

Now I run this strcpy

Result = strcpy(Source,Destination);

Now I can verify, using same approach as before , that
Result = 123 - AKA orignal Source, it was Result init before strcpy was run.
and Source is STILL 123.

Result suppose to be Source ( source destination swap) , but I expect the Source to be COPY of the original Destination AKA 456

What am I doing wrong?
strcpy executes giving correct return, but unmodified Destination.
Am I doing the initialization correctly?

Am I nuts?

Standard stdio using GCC compiler /tools on Arduino IDE.
Thank for your help.
Vaclav
Viewing all 3781 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>