Quantcast
Channel: Visual C forum
Viewing all 15302 articles
Browse latest View live

Region to paint is always zero in windows callback function for WS_CHILD windows

$
0
0

I try paint on overlapped and child windows using WinApi. For overlapped is OK, but for WS_CHILD dirty/invalidate rect ps.rcPaint is always (0,0,0,0)

I add WS_OVERLAPPEDWINDOW to WS_CHILD window to better seeing. Pivotal is "if ((style & WS_CHILD) != 0) "

It is a Windows error?

#include <windows.h>

LRESULT CALLBACK WndProc(HWND hWnd,
                         UINT message,
                         WPARAM wParam,
                         LPARAM lParam);

int RegClass(HINSTANCE hInstance,LPCTSTR lpszClassName)
{
    WNDCLASS wc;
    wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hInstance;
    wc.lpfnWndProc = WndProc;
    wc.lpszClassName = (LPCTSTR)lpszClassName;
    wc.lpszMenuName = (LPCTSTR)NULL;
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
    wc.hCursor = (HCURSOR)LoadCursor(NULL,IDC_CROSS);
    wc.hIcon = (HICON)LoadIcon(NULL,IDI_APPLICATION);
    return RegisterClass(&wc);
}

int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nShowCmd)
{
    HWND hWnd0, hWnd1;
    MSG message;

    static LPCTSTR lpszClName = L"Wnd Class";
    static LPCTSTR lpszCl0Name = L"Child Class";
    if(!RegClass(hInstance,lpszClName))
        exit(0);
    if(!RegClass(hInstance,lpszCl0Name))
        exit(0);

    hWnd0 = CreateWindow(
        lpszClName,
        L"Overlapped",
        WS_OVERLAPPEDWINDOW | WS_VISIBLE,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        800,
        600,
        0,
        0,
        hInstance,
        NULL
        );

    hWnd1 = CreateWindow(
        lpszClName,
        L"Child",
        WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CHILD,
        100,
        100,
        80,
        60,
        hWnd0,
        0,
        hInstance,
        NULL
        );

    ShowWindow(hWnd0,SW_SHOWNORMAL);
    UpdateWindow(hWnd0);

    ShowWindow(hWnd1,SW_SHOWNORMAL);
    UpdateWindow(hWnd1);

    while (GetMessage(&message,0,0,0))
    {
        TranslateMessage(&message);
        DispatchMessage(&message);
    }

    return message.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd,
                         UINT message,
                         WPARAM wParam,
                         LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage(0);       /* send a WM_QUIT to the message queue */
            break;
        case WM_ERASEBKGND:
            {
                if (true)
                {
                    PAINTSTRUCT ps;
                    HDC hdc = BeginPaint(hWnd, &ps);
                    HBRUSH hBrush = CreateSolidBrush(RGB(255, 0, 0));
		    unsigned style = GetWindowLong(hWnd, GWL_STYLE);
		    if ((style & WS_CHILD) != 0)
				FillRect((HDC)wParam, &ps.rcPaint, hBrush);
                    DeleteObject(hBrush);
                    EndPaint(hWnd, &ps);
                }
            }
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}


Network Problem

$
0
0

I am building a simple network application using windows sockets and I have had trouble getting it to work in my environment.  I will submit code if I can get past my current issue and it still doesn't work.

I have two machines on a private network, 192.168.3.x  I have a Windows 7 machine and a Windows 10 machine on the network.

From the Windows 7 machine I can ping the local machine 192.168.3.1 and I can ping the windows 10 machine 192.168.3.5 successfully. From the Windows 10 machine I can ping the local machine 192.168.3.5 but I cannot ping the windows 7 machine, Request Timed Out.

I suspect it has something to do with the Windows 10 firewall but don't understand enough at this point to isolate the issue. Any guidance would be appreciated.

Windows Media Player Control, hang up during playback

$
0
0
i am developing an application for playing wmv with windows media player control.

Windows Media Player Controls are below.
・IWMPPlayer4
・IWMPControls
・IWMPSettings
・IWMPMedia

but, it will hung up during video playback on rare occasion.
i can confirmed on windows7 32bit pc this problem. 

I've got a dump file below.
FAULTING_IP:
KERNELBASE!RaiseException+58
756a812f c9              leave

EXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 756a812f (KERNELBASE!RaiseException+0x00000058)
   ExceptionCode: c0000002
  ExceptionFlags: 00000001
NumberParameters: 0

CONTEXT:  00000000 -- (.cxr 0x0;r)
eax=00000000 ebx=0a00f630 ecx=00000400 edx=00000000 esi=00000002 edi=00000000
eip=776f71b4 esp=0a00f5e0 ebp=0a00f67c iopl=0         nv up ei pl zr na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246
ntdll!KiFastSystemCallRet:
776f71b4 c3              ret

PROCESS_NAME:  wplayer.exe
ERROR_CODE: (NTSTATUS) 0xc0000002 - {
EXCEPTION_CODE: (NTSTATUS) 0xc0000002 - {
NTGLOBALFLAG:  0
APPLICATION_VERIFIER_FLAGS:  0
APP:  wplayer.exe
ANALYSIS_VERSION: 6.3.9600.17336 (debuggers(dbg).150226-1500) x86fre
FAULTING_THREAD:  00001520
DEFAULT_BUCKET_ID:  STATUS_NOT_IMPLEMENTED
PRIMARY_PROBLEM_CLASS:  STATUS_NOT_IMPLEMENTED
BUGCHECK_STR:  APPLICATION_FAULT_STATUS_NOT_IMPLEMENTED
LAST_CONTROL_TRANSFER:  from 77416ec2 to 756a812f

STACK_TEXT:
0a00fc74 77416ec2 c0000002 00000001 00000000 KERNELBASE!RaiseException+0x58
0a00fc88 66af4b91 007fd280 66c48d4c 0a00fcc4 msvcrt!_purecall+0x11
0a00fc9c 66af7700 007c6ef8 0a00fcc4 00000000 wmp!CWMPGraphManager::GetCurrentMedia+0x4d
0a00fcd0 66af76b4 0a00fd24 00000000 007c6f90 wmp!CWMPControl::AdjustCurrentPositionForStartTime+0x3e
0a00fcec 66c07179 007c6f90 0a00fd24 00000000 wmp!CWMPControl::get_currentPosition+0x7a
0a00fd04 00c2a827 007cac44 0a00fd24 328a979c wmp!CIWMPNetworkSecurityWrapper::get_bufferingCount+0x36
WARNING: Stack unwind information not available. Following frames may be wrong.
0a00fd44 00c2b299 328a97a8 00000000 007a2c38 wplayer+0xa827
0a00fd70 00c31b35 00000000 328a9770 00000000 wplayer+0xb299
0a00fda8 00c31bbf 00000000 0a00fdc0 7617ee6c wplayer+0x11b35
0a00fdb4 7617ee6c 007a2c38 0a00fe00 77713ab3 wplayer+0x11bbf
0a00fdc0 77713ab3 007a2c38 7dc8b86e 00000000 kernel32!BaseThreadInitThunk+0xe
0a00fe00 77713a86 00c31b5b 007a2c38 00000000 ntdll!__RtlUserThreadStart+0x70
0a00fe18 00000000 00c31b5b 007a2c38 00000000 ntdll!_RtlUserThreadStart+0x1b

FOLLOWUP_IP:
wmp!CWMPGraphManager::GetCurrentMedia+4d
66af4b91 5d              pop     ebp

SYMBOL_STACK_INDEX:  2
SYMBOL_NAME:  wmp!CWMPGraphManager::GetCurrentMedia+4d
FOLLOWUP_NAME:  MachineOwner
MODULE_NAME: wmp
IMAGE_NAME:  wmp.dll
DEBUG_FLR_IMAGE_TIMESTAMP:  55411dac
STACK_COMMAND:  ~14s; .ecxr ; kb
FAILURE_BUCKET_ID:  STATUS_NOT_IMPLEMENTED_c0000002_wmp.dll!CWMPGraphManager::GetCurrentMedia
BUCKET_ID:  APPLICATION_FAULT_STATUS_NOT_IMPLEMENTED_wmp!CWMPGraphManager::GetCurrentMedia+4d
ANALYSIS_SOURCE:  UM
FAILURE_ID_HASH_STRING:  um:status_not_implemented_c0000002_wmp.dll!cwmpgraphmanager::getcurrentmedia
FAILURE_ID_HASH:  {2ac96fdf-730a-e2ab-fcee-863ab99151b2}
Followup: MachineOwner

please tell me, what is the possible reason of error? 
and, does anyone have any solutions?

developed by
Windows7 64bit
Visual Studio 2010 C++

thanks

RichEdit50W doesn't display "�" character.

$
0
0

I noticed that � character is not displayed in RichEdit50W control. Previous version: RichEdit20W displayed it.

Is there something I can do about it?

Thank you.

Security Update for Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package (KB2538242) Installing Multiple Times

$
0
0

I'm on Windows 10. All the replies and fixes I've seen relate to 7 and 8. Is there a fix for Windows 10?

The update has been installing most days, sometimes up to 8 times a day, so my update history is getting ridiculous! Help

visual studion 2015 setup

$
0
0

Having upgraded to Windows 10 I also installed visual studio 2015, but it fails immediately. Please can somone hlpe me get it working. This is the error that I get:

1>------ Build started: Project: VCamCOMTest, Configuration: Debug Win32 ------

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry.  TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.

1>TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the file specified.

1>

1>

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

C++/CLI using variable between buttons

$
0
0

I have error with StreamReader: "read" variable that I use in different buttons to pass text file address. There is a example of code below.

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

OpenFileDialog ^ofd = gcnew OpenFileDialog();

if (ofd->ShowDialog() == System::Windows::Forms::DialogResult::OK) {
StreamReader ^read = gcnew StreamReader(File::OpenRead(ofd->FileName));//this is variable read
textBox1->Text = read->ReadToEnd();

 }
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {

		String^ text = textBox1->Text;
		auto lines = File::ReadAllLines(read);//This variable I use here
		String ^ line = lines[0];
}

Error c2065 need help

$
0
0
#include <iomanip>
#include <iostream>
#include <cmath>

#ifndef SavingsAccount_H
#define SavingsAccount_h


class SavingAccount: BankAccount
{
//data member
double minBal;
double balance;
double accountNumber;

public:
//Constructor

SavingAccount(int ano , double amount):BankAccount(ano, amount)
{
minBal=500;
}
//to perform deposit
//overriding base class function
double depositAmount(double damount)
{
balance=balance+damount;
return(balance);
}
//to perform withdraw
//overriding base class function
double withDrawAmount(double wamount)
{
if(check())
balance=balance-wamount;
else
cout<<"you have in sufficient balance"<<endl;
return(balance);
}
//Setting minimum balance
void setMinBal(double mbal)
{
minBal=mbal;
}
//Checking for account sufficiency
bool check()
{
if(balance<minBal)
return(false);
else
return(true);
}
//Showing account information
void showAccountInfo()
{
cout<<"Account Number :"<<accountNumber<<endl;
cout<<"Account Balance:"<<balance<<endl;
}
};
#endif

Error1error C2065: 'cout' : undeclared identifierc:\users\willr_000\documents\visual studio 2012\projects\bank accounts project- will and travis\bank accounts project- will and travis\bankaccount.h441Bank Accounts Project- will and travis

so confused why its cout is a undeclared identifier???


How to save WMF image file.

$
0
0

Hi,

I am new to this topic.

i am using this method  --->  m_image.Save(lpszPathName);

it saves .bmp, .jpeg, .png, .gif, .tif  formats but not saves the WMF/EMF Format.

what i do for saving the image as .wmf format.

please help me.

Thanks in advance.



sree2sri

For MFC ON_EVENT function,how to realize it from the windows api level

$
0
0

In MFC,create ActiveX event handler such as below:

BEGIN_EVENTSINK_MAP(CTestExecDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CTestExecDlg)
ON_EVENT(CTestExecDlg, IDC_APPLICATIONMGR, 1 /* ExitApplication */, OnExitApplication_ApplicationMgr, VTS_NONE)

//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

How could I realize it from the windows api level?

Thanks


How to convert CBitmap to WMF file using C++?

$
0
0

Hi,

How to convert CBitmap to WMF file using C++?

Thanks in advance.

AssemblyInfo.cpp(1): warning C4005: '__CLR_VER' : macro redefinition || Slutprojekt.cpp(3): warning C4005: '__CLR_VER' : macro redefinition

$
0
0

I need help with the following error:

1>------ Build started: Project: Slutprojekt, Configuration: Debug Win32 ------
1>  AssemblyInfo.cpp
1>AssemblyInfo.cpp(1): warning C4005: '__CLR_VER' : macro redefinition
1>          command-line arguments :  see previous definition of '__CLR_VER'
1>AssemblyInfo.cpp(1): warning C4651: '/D__CLR_VER=40600127' specified for precompiled header but not for current compile
1>AssemblyInfo.cpp(1): fatal error C1093: API call 'ImportFile' failed '0x80070003' : ErrorMessage: Can't find the path.// translated from Swedish
1>  
1>  Description: Can't find the path.
1>  HelpFile: complib.hlp
1>  Slutprojekt.cpp
1>Slutprojekt.cpp(3): warning C4005: '__CLR_VER' : macro redefinition
1>          command-line arguments :  see previous definition of '__CLR_VER'
1>Slutprojekt.cpp(3): warning C4651: '/D__CLR_VER=40600127' specified for precompiled header but not for current compile
1>Slutprojekt.cpp(3): fatal error C1093: API call 'ImportFile' failed '0x80070003' : ErrorMessage: Can't find the path.//Translated from swedish.
1>  
1>  Description: Can't find the path.
1>  HelpFile: complib.hlp
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



C++/CLI Illegal characters in path

$
0
0

There is a opened file and code that reads first line but after running the code I got error message that says "Illegal characters in path". All characters are latin so I don't understand where is a problem ?

String^ text = textBox1->Text;

auto lines = File::ReadAllLines(text);
String ^ sometext = lines[0];

datagridview->Rows[0]->Cells[0]->Value = sometext;

Windows 10: CreateFile() for a named pipe returns ERROR_PIPE_BUSY always

$
0
0

Hi,

I'm working on a legacy application which has been working successfully for years on Windows 7, but fails in some cases on Windows 10. 

One such case is use of named pipes. A client application trying to access a named pipe using CreateFile() always returns the error ERROR_PIPE_BUSY, and goes into an infinite loop since we try to do WaitNamedPipe() intermittently, similar to https://msdn.microsoft.com/en-us/library/windows/desktop/aa365592(v=vs.85).aspx

I've checked the code, and found that CloseHandle() is being called correctly. Any clues why this should fail consistently on Windows 10?

TIA.

GDI+ RotateFlip is not rotating .WMF Image?

$
0
0

Hi,

In C++, I used GDI+ RotateFlip to rotate the .WMF image using below code but it is not rotating the WMF image.

      Graphics graphics(hdc);
      Image image(L"Crayons.WMF");   
      graphics.DrawImage(&image, 10, 10, image.GetWidth(), image.GetHeight());
      image.RotateFlip(Rotate90FlipY);

If I use the same code on .bmp, .jpg image it is working.

Will RotateFlip support WMF image?

Thanks in advance.



copiar de char[] a char*

$
0
0

I've tried to copy the value passed to main's second argument, like this

int main(int argc, char *argv[]) {
	char* token;
	std::strcpy(token, argv[1]);
}

but the compiler cannot deal with the 'constantness' of the second parameter in strcpy().

Can any one help understand how to do this?

Thanks!

Faça um módulo 'vetores.h' e 'vetores.cpp' com rotinas

$
0
0

/*6. Faça um módulo vetores.h e vetores.cpp com as seguintes rotinas:
//inicializa o vetor com todos os elementos iguais a 0
- void InicializarVetor(int Vetor[], int tamanho);
//Recebe os números do usuario
- void ReceberVetor(int Vetor[], int tamanho);
//Retorna o maior numero do vetor
- int MaiorNroVetor(int Vetor[], int tamanho);
//Retorna a posição do numero no vetor
- int PosicaoNroVetor(int Vetor[], int tamanho, int Nro);
//Retorna a freqüência de um numero no vetor
- int PosicaoNroVetor(int Vetor[], int tamanho, int Nro);*/
#include <stdlib.h>
#include <iostream>
#include "vetores.h"
#define tamanho 5
using namespace std;

int main()
{

    int vet[0];
    int k=0,y=0;

    cout << "\n Entre com os elementos:\a";
    for(k=0;k<tamanho;k++)
    {
        cin >> vet[k];
        InicializarVetor(vet,k);
    }
    cout << "\n Entre novamente com os elementos:\a";
    for(y=0;y<tamanho;y++)
    {
        cin >> vet[y];
        ReceberVetor(vet,y);
    }


    return 0;

#include "vetores.h"

void InicializarVetor(int Vetor[], int tamanho)
{
    int i=0;
    for(i=0;i<tamanho;i++)
    {
        Vetor[i]=0;
    }
}

void ReceberVetor(int Vetor[], int tamanho)
{
   int i=0;
    for(i=0;i<tamanho;i++)
    {
        cin >> Vetor[i];
    }
}
int MaiorNroVetor(int Vetor[], int tamanho)
{
    int cont=0;
    int maior=0;

    for(cont=0;cont<tamanho;cont++)
    {
        cin >> Vetor[cont];
        maior = Vetor[0];
        if(maior < Vetor[cont])
        {
            maior = Vetor[cont];
        }
    }
}
int PosicaoNroVetor(int Vetor[], int tamanho, int Nro)
{
    int pos=0;
    int cont=0;
    //cout << "\nEntre com posicao no vetor:\n";
    for(cont=0;cont<tamanho;cont++)
    {
        cin >> Vetor[pos];
    }
    return 0; //deve ser implementada
}
int FrequenciaNroVetor(int Vetor[], int tamanho, int Nro)
{
    return 0; //deve ser implementada
}

#ifndef GEOMETRIA_H_INCLUDED
#define GEOMETRIA_H_INCLUDED
#include <stdlib.h>

#include <iostream>

using namespace std;

void InicializarVetor(int Vetor[], int tamanho);

void ReceberVetor(int Vetor[], int tamanho);

int MaiorNroVetor(int Vetor[], int tamanho);

int PosicaoNroVetor(int Vetor[], int tamanho, int Nro);

int FrequenciaNroVetor(int Vetor[], int tamanho, int Nro);

#endif //Módulo vetores.h;//

How to pass an image from C# console application to VC++ ATL COM dll

$
0
0

Hi,

I have created a ATL COM DLL to get an Image from C#

STDMETHODIMP CRotationApp::RotationAngle(VARIANT* var, LONG width, LONG height,VARIANT* angle)
{

return S_OK;

}

VARIANT* var --> to receive an Image from C#

Kindly give your solution to pass an Byte[] array from C# to C++ dll function RotationAngle().

Thank you,

Regards,

Naveen


Sqlite in C++

$
0
0
I' m building a mobile application in C++ cross-platform and i would like to programmatically create my database using Sqlite in Visual Studio C++.  Unfortunately i can't find any tutorials which can help me. Can someone please help me? 

How to pass a unicode string to the FDF Toolkit (adobe)?

$
0
0

Hi

I am very confused here. According to the FDF Toolkit it states:

	/* IMPORTANT NOTE about all strings in this API: All strings must be null-terminated.
	Every call specifies which encodings are acceptable for every string. Strings that are in Host-
	or PDFDocEncoding end with a single null byte. Strings in Unicode have '\xfe' as byte 0
	and '\xff' as byte 1. Additionally, they must be terminated with 2 null bytes.
	Field names are always in PDFDoc encoding, and they always represent the fully qualified
	name of the field (e.g. "employee.name.last").
	The PDFDocEncoding is described in Appendix D of the PDF Reference, Second Edition.
	*/

So, I have a CString which has a bit of Arabic text. I am trying to convert it into a suitable buffer (char *) so I can use the FDFSetValue call.

I tried:

CString strArabic = _T("كانون الاول");

strArabic.Insert(0, '\xfe');
strArabic.Insert(1, '\xff');
strArabic += '\0';

LPCSTR zBuffer = (LPCSTR)strArabic.GetBuffer();

Doesn't work. The resulting FDF document is not right.

I have heard about the PDFEncoding and think it might be supposed to be like that since the original FDF file is in ANSI format.

I am very confused and appreciate any pointers.

Andrew

Viewing all 15302 articles
Browse latest View live


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