Quantcast
Channel: CodeGuru Forums - C++ and WinAPI
Viewing all 583 articles
Browse latest View live

strange function calls?

$
0
0
Hello everyone I'm very new to winapi...

can someone explain functions calls like this to me? never met it before in general c++

function (something_in_brackets)(another_someting_in_brackets) ;
or
typedef type (something_here)(something_here_again);

what I new was..function(parameters)..but to have two brackets after the function name ...
what is it that I've been missing all this while?

now some real examples..
Code:

CWA(comdlg32, GetSaveFileNameW)(&ofn);
//and
CWA(comdlg32, GetSaveFileNameW)(&ofn)


Creating a setup file in Visula studio using installshield

$
0
0
How to include third party software setup in installshield using visual studio.



Thanks and Regards,
Jeevan

c++ macro syntax

$
0
0
I'm learning winapi and I'm going through this source I found online and there is this macro which is making me go...
here goes the snippet...
Code:

#define CWA(dll, api)                ::api
and was used like so

Code:

CWA(user32, DialogBoxParamW)(currentModule, MAKEINTRESOURCEW(DIALOG_MAIN), NULL, mainDialogProc, NULL);
but going through my c++ books, this macro syntax does not conform to what is in my books getting me a little bit
confused, master victorN on this forum linked me a page on stackoverflow which touched on the subject but I still can't get how the syntax look different from that in my c++ books... the double brackets is confusing me..what syntax is this??? CWA()() ; ???
the general syntax I know of should be like this ...
thanks
Code:

// function macro
#include <iostream>
using namespace std;

#define getmax(a,b) ((a)>(b)?(a):(b))

int main()
{
  int x=5, y;
  y= getmax(x,2);
  cout << y << endl;
  cout << getmax(7,x) << endl;
  return 0;
}

Image processing algorithms: erosion and dilation

$
0
0
Hi,i need to implement erosion and dilation algorithms in c++, can anyone suggest me The code or preudoce of this algorithms?
Thank's.

VS 2015 display issue

$
0
0
I was updating some turn of the century code when I ran into this anomaly using Visual Studio 2015 Community c++.
It appears to be a display issue because I have an app that produces source (PowerBASIC) from a running applications window. The sizes for the window and the edit controls match the sizes used in the c++ code for both displays .
I tested with the TDM-GCC compiler (http://tdm-gcc.tdragon.net/) for the c++ code and also using PellesC compiler.
I did a few preliminary tests compiling on Win10 and running on Win7 and Compiling on Win7 and running on Win7. I also tested on different computers with different monitor resolutions just to be sure. All results were the same. The Visual Studio 2015 created app did not display correctly. Any insights?
Thank you for your time.
James

Code:

#include <windows.h>

// *************************************************
//            User Defined Constants
// *************************************************

#define AppName "Ec03"
#define Caption "Edit Controls"
#define ID_Edit1 101
#define ID_Edit2 102
// *************************************************
//            User Global Variables
// *************************************************
static HWND    Form1;
static HWND    Edit1;
static HWND    Edit2;

// *************************************************
//              Standard Macros
// *************************************************

#define BOR |


// *************************************************
//              User Prototypes
// *************************************************

void    FormLoad (HINSTANCE);
int    WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int);
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);


void FormLoad (HINSTANCE  hInst)
{
    float    fHeight = 312;
    float    fWidth = 330;
    Form1 = CreateWindowEx( WS_EX_WINDOWEDGE, AppName, Caption, WS_POPUP  BOR  WS_VISIBLE  BOR  WS_CLIPSIBLINGS  BOR  WS_CAPTION  BOR  WS_SYSMENU  BOR  DS_MODALFRAME, ( GetSystemMetrics( SM_CXSCREEN) - fWidth) / 2, ( GetSystemMetrics( SM_CYSCREEN) - fHeight) / 2, fWidth, fHeight, NULL, (HMENU) NULL, hInst, NULL);
    Edit1 = CreateWindowEx( 0, "edit", NULL, WS_CHILD  BOR  WS_VISIBLE  BOR  WS_BORDER  BOR  ES_AUTOVSCROLL  BOR  ES_WANTRETURN  BOR  ES_AUTOHSCROLL  BOR  ES_MULTILINE, 14, 16, 300, 110, Form1, (HMENU) ID_Edit1, hInst, NULL);
    Edit2 = CreateWindowEx( 0, "edit", NULL, WS_CHILD  BOR  WS_VISIBLE  BOR  WS_BORDER  BOR  ES_AUTOVSCROLL  BOR  ES_WANTRETURN  BOR  ES_AUTOHSCROLL  BOR  ES_MULTILINE, 14, 158, 300, 116, Form1, (HMENU) ID_Edit2, hInst, NULL);
    ShowWindow(Form1, SW_SHOW);
}

int WINAPI WinMain (HINSTANCE  hInst, HINSTANCE  hPrev, LPSTR  CmdLine, int CmdShow)
{
    MSG      uMsg = {0};
    WNDCLASSEX  wcx = {0};
    wcx.cbSize = sizeof( wcx);
    wcx.style = CS_HREDRAW  BOR  CS_VREDRAW;
    wcx.lpfnWndProc = WndProc;
    wcx.cbClsExtra = 0;
    wcx.cbWndExtra = 0;
    wcx.hInstance = hInst;
    wcx.hIcon = LoadIcon( NULL, IDI_WINLOGO);
    wcx.hCursor = LoadCursor( NULL, IDC_ARROW);
    wcx.hbrBackground = ( HBRUSH) GetStockObject( WHITE_BRUSH);
    wcx.lpszMenuName = NULL;
    wcx.lpszClassName = AppName;
    RegisterClassEx( &wcx);
    FormLoad(hInst);
    while(GetMessage( &uMsg, NULL, 0, 0))
    {
        TranslateMessage( &uMsg);
        DispatchMessage( &uMsg);
    }

    return uMsg.wParam;
}

LRESULT CALLBACK WndProc (HWND hWnd, UINT Msg, WPARAM  wParam, LPARAM  lParam)
{
    switch(Msg)
    {
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hWnd, Msg, wParam, lParam);
}

Visual Studio 2015 batch file
Quote:

@SETLOCAL
@ECHO OFF
SET XTYPE=x86_amd64
CALL "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %XTYPE%
ECHO ON
cl.exe /O1 /Gd /EHsc /MT %1.cpp /Fe"%1.exe" /link /SUBSYSTEM:WINDOWS kernel32.lib user32.lib gdi32.lib
TDM-GCC batch file
Quote:

@SETLOCAL
@ECHO OFF
SET MINGW=C:\TDM-GCC-64
SET PATH=%MINGW%\bin;%PATH%
ECHO ON
g++ %1.cpp -o %1.exe -mwindows -lmingw32 -lkernel32 -luser32 -lgdi32
Attached Images
  
Attached Files

how use SendInput() for a non focus window?

$
0
0
i did a nice functions for use the SendInput():
Code:

//Simulate the press key:
void inputDown(INPUT &ip, WORD wrdKey, int MouseX=-1, int MouseY=-1)
{
    if(wrdKey == VK_LBUTTON || wrdKey == VK_RBUTTON || wrdKey == VK_MBUTTON || wrdKey == VK_XBUTTON1 || wrdKey == VK_XBUTTON2)
    {
        INPUT input;
        input.type = INPUT_MOUSE;
        input.mi.mouseData=0;
        POINT mousepos;
        GetCursorPos(&mousepos);
        if(MouseX==-1)
            input.mi.dx =  mousepos.x;//x being coord in pixels
        else
          input.mi.dx =MouseX;
        if(MouseX==-1)
            input.mi.dy = mousepos.y;//y being coord in pixels
        else
            input.mi.dy =MouseY;
        if(wrdKey==VK_LBUTTON)
            input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
        else if(wrdKey==VK_RBUTTON)
            input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
        else if(wrdKey==VK_MBUTTON)
            input.mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
        else if(wrdKey==VK_XBUTTON1 || wrdKey==VK_XBUTTON2)
            input.mi.dwFlags = MOUSEEVENTF_XDOWN;
        SendInput(1,&input,sizeof(input));
    }
    else
    {
        ip.type = INPUT_KEYBOARD;
        ip.ki.wScan = 0; // hardware scan code for key
        ip.ki.time = 0;
        ip.ki.dwExtraInfo = 0;

        ip.ki.wVk = wrdKey;
        ip.ki.dwFlags = 0; // 0 for key press
        SendInput(1, &ip, sizeof(INPUT));
    }

}


//Simulate the Release key:
void inputRelease(INPUT &ip, WORD wrdKey, int MouseX=-1, int MouseY=-1)
{
    if(wrdKey == VK_LBUTTON || wrdKey == VK_RBUTTON || wrdKey == VK_MBUTTON || wrdKey == VK_XBUTTON1 || wrdKey == VK_XBUTTON2)
    {
        INPUT input;
        input.type = INPUT_MOUSE;
        input.mi.mouseData=0;
        POINT mousepos;
        GetCursorPos(&mousepos);
        if(MouseX==-1)
            input.mi.dx =  mousepos.x;//x being coord in pixels
        else
          input.mi.dx =MouseX;
        if(MouseX==-1)
            input.mi.dy =  mousepos.y;//y being coord in pixels
        else
            input.mi.dy =MouseY;
        if(wrdKey==VK_LBUTTON)
            input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
        else if(wrdKey==VK_RBUTTON)
            input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
        else if(wrdKey==VK_MBUTTON)
            input.mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
        else if(wrdKey==VK_XBUTTON1 || wrdKey==VK_XBUTTON2)
            input.mi.dwFlags = MOUSEEVENTF_XUP;
        SendInput(1,&input,sizeof(input));
    }
    else
    {
        ip.type = INPUT_KEYBOARD;
        ip.ki.wScan = 0; // hardware scan code for key
        ip.ki.time = 0;
        ip.ki.dwExtraInfo = 0;

        ip.ki.wVk =wrdKey;
        ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release
        SendInput(1, &ip, sizeof(INPUT));
    }

}

//combine the inputDown with inputUp functions:
void inputPress(WORD wrdKey, WORD blnShift=-1,  int MouseX=-1, int MouseY=-1)
{
    INPUT ip;
    //pressing keys
    //remember: with combination keys, 1st the control\****\menu key and then the letter key!!
    if((blnShift&VK_CONTROL)==VK_CONTROL)
    {
        inputDown(ip,blnShift);
    }
    if((blnShift&VK_MENU)==VK_MENU)
    {
        inputDown(ip,blnShift);
    }
    if((blnShift&VK_SHIFT)==VK_SHIFT)
    {
        inputDown(ip,blnShift);
    }

    inputDown(ip,wrdKey,MouseX,MouseY);

    //release key:
    inputRelease(ip,wrdKey,MouseX,MouseY);

    if((blnShift&VK_CONTROL)==VK_CONTROL)
    {
        inputRelease(ip,blnShift);
    }
    if((blnShift&VK_MENU)==VK_MENU)
    {
        inputRelease(ip,blnShift);
    }
    if((blnShift& VK_SHIFT)==VK_SHIFT)
    {
        inputRelease(ip,blnShift);
    }
}

but these code only works for a focus window.
how can i change these code for works with a non focus window(like choose a window)?

[RESOLVED] how use SendInput() for a non focus window?

$
0
0
i did a nice functions for use the SendInput():
Code:

//Simulate the press key:
void inputDown(INPUT &ip, WORD wrdKey, int MouseX=-1, int MouseY=-1)
{
    if(wrdKey == VK_LBUTTON || wrdKey == VK_RBUTTON || wrdKey == VK_MBUTTON || wrdKey == VK_XBUTTON1 || wrdKey == VK_XBUTTON2)
    {
        INPUT input;
        input.type = INPUT_MOUSE;
        input.mi.mouseData=0;
        POINT mousepos;
        GetCursorPos(&mousepos);
        if(MouseX==-1)
            input.mi.dx =  mousepos.x;//x being coord in pixels
        else
          input.mi.dx =MouseX;
        if(MouseX==-1)
            input.mi.dy = mousepos.y;//y being coord in pixels
        else
            input.mi.dy =MouseY;
        if(wrdKey==VK_LBUTTON)
            input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
        else if(wrdKey==VK_RBUTTON)
            input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
        else if(wrdKey==VK_MBUTTON)
            input.mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
        else if(wrdKey==VK_XBUTTON1 || wrdKey==VK_XBUTTON2)
            input.mi.dwFlags = MOUSEEVENTF_XDOWN;
        SendInput(1,&input,sizeof(input));
    }
    else
    {
        ip.type = INPUT_KEYBOARD;
        ip.ki.wScan = 0; // hardware scan code for key
        ip.ki.time = 0;
        ip.ki.dwExtraInfo = 0;

        ip.ki.wVk = wrdKey;
        ip.ki.dwFlags = 0; // 0 for key press
        SendInput(1, &ip, sizeof(INPUT));
    }

}


//Simulate the Release key:
void inputRelease(INPUT &ip, WORD wrdKey, int MouseX=-1, int MouseY=-1)
{
    if(wrdKey == VK_LBUTTON || wrdKey == VK_RBUTTON || wrdKey == VK_MBUTTON || wrdKey == VK_XBUTTON1 || wrdKey == VK_XBUTTON2)
    {
        INPUT input;
        input.type = INPUT_MOUSE;
        input.mi.mouseData=0;
        POINT mousepos;
        GetCursorPos(&mousepos);
        if(MouseX==-1)
            input.mi.dx =  mousepos.x;//x being coord in pixels
        else
          input.mi.dx =MouseX;
        if(MouseX==-1)
            input.mi.dy =  mousepos.y;//y being coord in pixels
        else
            input.mi.dy =MouseY;
        if(wrdKey==VK_LBUTTON)
            input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
        else if(wrdKey==VK_RBUTTON)
            input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
        else if(wrdKey==VK_MBUTTON)
            input.mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
        else if(wrdKey==VK_XBUTTON1 || wrdKey==VK_XBUTTON2)
            input.mi.dwFlags = MOUSEEVENTF_XUP;
        SendInput(1,&input,sizeof(input));
    }
    else
    {
        ip.type = INPUT_KEYBOARD;
        ip.ki.wScan = 0; // hardware scan code for key
        ip.ki.time = 0;
        ip.ki.dwExtraInfo = 0;

        ip.ki.wVk =wrdKey;
        ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release
        SendInput(1, &ip, sizeof(INPUT));
    }

}

//combine the inputDown with inputUp functions:
void inputPress(WORD wrdKey, WORD blnShift=-1,  int MouseX=-1, int MouseY=-1)
{
    INPUT ip;
    //pressing keys
    //remember: with combination keys, 1st the control\****\menu key and then the letter key!!
    if((blnShift&VK_CONTROL)==VK_CONTROL)
    {
        inputDown(ip,blnShift);
    }
    if((blnShift&VK_MENU)==VK_MENU)
    {
        inputDown(ip,blnShift);
    }
    if((blnShift&VK_SHIFT)==VK_SHIFT)
    {
        inputDown(ip,blnShift);
    }

    inputDown(ip,wrdKey,MouseX,MouseY);

    //release key:
    inputRelease(ip,wrdKey,MouseX,MouseY);

    if((blnShift&VK_CONTROL)==VK_CONTROL)
    {
        inputRelease(ip,blnShift);
    }
    if((blnShift&VK_MENU)==VK_MENU)
    {
        inputRelease(ip,blnShift);
    }
    if((blnShift& VK_SHIFT)==VK_SHIFT)
    {
        inputRelease(ip,blnShift);
    }
}

but these code only works for a focus window.
how can i change these code for works with a non focus window(like choose a window)?

error LNK2001: unresolved external symbol

$
0
0
i am using singulton pattern and visual studio 2010. getting this linker error.
error LNK2001: unresolved external symbol "public: static class CAIUInterface * __cdecl CAIUInterface::GetInstance(void)" (? GetInstance@CAIUInterface@@SAPAV1@XZ) D:\15008_CPDS\CPDS\Transmitter.obj CPDS

// this is header file.
class CAIUInterface
{
private:
static bool m_bInstanceFlag; the status of single instance creation.
static CAIUInterface *m_objAIU;
}

// here is function definition.
CAIUInterface* CAIUInterface::GetInstance()
{
///Step1: Check whether instance is created
if (!m_bInstanceFlag)
{
///Step2: If instance is not created, create it newly and update the instance status to true.
m_objAIU = new CAIUInterface();
m_bInstanceFlag = true;
}

///Step3: Return the pointer object or address of CAIUInterface instance.
return m_objAIU;
}



//i am using like following.
int CAppAIUInterface::CloseApp()
{
siResult = CAIUInterface::GetInstance()->Close();

}

functions in .dlls

$
0
0
So is there a documentation and if not how do I get to know all the functions and their parameters and possibly what they do in each .dll..for example the kernel32.dll, user32.dll ecc ecc...?
thanks

Multicolumn list in WinApi

$
0
0
How can I do a Multicolumn listbox, 3x10, where 3 are "song", "year", "artist", and 10 the amount of elements that sould be in the list?

#include <windows.h>
#include <CommDlg.h>
#include "resource.h"
#include <commctrl.h>
#include <stdio.h>
#include <winuser.h>

using namespace std;

HWND hDlg;
HINSTANCE ghDlg;

BOOL CALLBACK MsgDlgProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK MsgDlg2Proc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK MsgDlg3Proc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK MsgDlg4Proc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK MsgDlg5Proc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK MsgDlg6Proc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK MsgDlg7Proc(HWND, UINT, WPARAM, LPARAM);

BOOL CALLBACK MsgDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {

switch (msg) {

case WM_INITDIALOG:
return true;

case WM_COMMAND: {

switch (LOWORD(wParam)) {

case IDC_BUTTON1: {
ShowWindow(hDlg, SW_HIDE);
DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG2), 0, MsgDlg2Proc);
break;
}

case IDC_BUTTON2: {
ShowWindow(hDlg, SW_HIDE);
DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG3), 0, MsgDlg3Proc);
break;
}

case IDC_BUTTON3: {
ShowWindow(hDlg, SW_HIDE);
DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG5), 0, MsgDlg5Proc);
break;
}

case IDC_BUTTON4: {
ShowWindow(hDlg, SW_HIDE);
DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG6), 0, MsgDlg6Proc);

break;
}

case IDC_BUTTON5: {
ShowWindow(hDlg, SW_HIDE);
DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG4), 0, MsgDlg4Proc);

break;
}

}
break;
}
case WM_CLOSE:
DestroyWindow(hDlg);
return true;
case WM_DESTROY:
PostQuitMessage(0);
return true;
}
return false;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR cmdLine, int showCmd){

hDlg = CreateDialog(ghDlg, MAKEINTRESOURCE(IDD_DIALOG1), 0, MsgDlgProc);

ShowWindow(hDlg, showCmd);

MSG msg;
ZeroMemory(&msg, sizeof(MSG));

while (GetMessage(&msg, 0, 0, 0)) {
if (hDlg == 0 || !IsDialogMessage(hDlg, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int)msg.wParam;
}

BOOL CALLBACK MsgDlg2Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {

case WM_INITDIALOG:
return true;

case WM_COMMAND: {
switch (LOWORD(wParam)) {
case IDC_BUTTON6: {
break;
}
case IDC_Examinar1: {
break;
}
case IDOK1: {
break;
}
case IDCANCEL1: {
ShowWindow(hDlg, SW_HIDE);
DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG1), 0, MsgDlgProc);
break;
}
}
}

case WM_CLOSE:
DestroyWindow(hDlg);
return true;
case WM_DESTROY:
PostQuitMessage(0);
return true;
}
return false;
}

BOOL CALLBACK MsgDlg3Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {

case WM_INITDIALOG:
return true;

case WM_COMMAND: {
switch (LOWORD(wParam)) {
case IDC_Regresar1: {
ShowWindow(hDlg, SW_HIDE);
DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG1), 0, MsgDlgProc);
break;
}
}
}

case WM_CLOSE:
DestroyWindow(hDlg);
return true;
case WM_DESTROY:
PostQuitMessage(0);
return true;
}
return false;
}

BOOL CALLBACK MsgDlg4Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {

case WM_INITDIALOG:
return true;

case WM_COMMAND: {
switch (LOWORD(wParam)) {

case IDC_Regresar2: {
ShowWindow(hDlg, SW_HIDE);
DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG1), 0, MsgDlgProc);
break;
}
case IDC_Play1: {
break;
}
case IDC_Stop1: {
break;
}
case IDC_Pause1: {
break;
}
case IDC_Rewind1: {
break;
}
case IDC_Forward1: {
break;
}
}
}

case WM_CLOSE:
DestroyWindow(hDlg);
return true;
case WM_DESTROY:
PostQuitMessage(0);
return true;
}
return false;
}

BOOL CALLBACK MsgDlg5Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {

case WM_INITDIALOG:
return true;

case WM_COMMAND: {
switch (LOWORD(wParam)) {

case IDOK2: {
break;
}
case IDCANCEL2: {
ShowWindow(hDlg, SW_HIDE);
DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG1), 0, MsgDlgProc);
break;
}
}
}

case WM_CLOSE:
DestroyWindow(hDlg);
return true;
case WM_DESTROY:
PostQuitMessage(0);
return true;
}
return false;
}

BOOL CALLBACK MsgDlg6Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {

case WM_INITDIALOG:
return true;

case WM_COMMAND: {
switch (LOWORD(wParam)) {

case IDC_Regresar3: {
ShowWindow(hDlg, SW_HIDE);
DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG1), 0, MsgDlgProc);
break;
}
case IDC_Prov1: {
ShowWindow(hDlg, SW_HIDE);
DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG7), 0, MsgDlg7Proc);
break;
}
}
}
case WM_CLOSE:
DestroyWindow(hDlg);
return true;
case WM_DESTROY:
PostQuitMessage(0);
return true;
}
return false;
}

BOOL CALLBACK MsgDlg7Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {

case WM_INITDIALOG:
return true;

case WM_COMMAND: {
switch (LOWORD(wParam)) {

case IDC_Regresar5: {
ShowWindow(hDlg, SW_HIDE);
DialogBox(ghDlg, MAKEINTRESOURCE(IDD_DIALOG6), 0, MsgDlg6Proc);
break;
}
case IDC_Play2: {
break;
}
case IDC_Stop2: {
break;
}
case IDC_Pause2: {
break;
}
case IDC_Rewind2: {
break;
}
case IDC_Forward2: {
break;
}
}
}

case WM_CLOSE:
DestroyWindow(hDlg);
return true;
case WM_DESTROY:
PostQuitMessage(0);
return true;
}
return false;
}




Thanks!

Structure Padding in visual basics tool.

$
0
0
We are trying to see the size of the structure its getting 8 bytes,and get padded with remaining bytes we want to use only 4 bytes only 32bit frame. How to make 32 bit frame. so that we want to use only 4 bytes,Can any one help me out in finding the solutions we are using Visual basics tool.


Code:

typedef struct STTCADispCtrl
{
        unsigned char label;
        unsigned char sdi:2;
        unsigned char ia:1;
        unsigned char As:2;
        unsigned char Att:1;
        unsigned char Dtif:1;
        unsigned int Range:9;
        unsigned char Ac:2;
        unsigned char Mil:3;
        unsigned char ssm:2;
        unsigned char parity:1;
}ST_TCAS_MODE_DISP_CTRL;

int main()
{

        ST_TCAS_MODE_DISP_CTRL display;

        printf("sizeof ST_TCAS_MODE_DISP_CTRL: %d sizeof unsigned int: %d\n", sizeof(display), sizeof(unsigned int));

        return 0;
}

What is the Windows Input Device for my keyboard?

$
0
0
I want to read from my Keyboard-Input-Device (Win32 Device Namespaces, \\.\). How can I decide which device is responsible for my keyboard. I can browse the available devices with the tool WinObj but I can not decide which device is the correct one.

I found an example where the device for input can be read/open with the function C++ function CreateFile("\\\\.\\interception00", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL).

Here is a link to the example: http://www.oblita.com/interception.html

On my PC there is no interception-device aviable. I looked with WinObj on an other PC and there were 20 interception-devices aviable. Why are these interception-devices not aviable on my PC ?

winap Dialogbox ..

$
0
0
so from the book I'm reading... windows programming, charles petzold ...
HTML Code:

-a dialog box procedure returns a BOOL.
-a dialogbox procedure does not need to process a WM_PAIN or WM_DESTROY messages. A dialog box procedure will  not receive a WM_CREATE message. Instead the dialogbox procedure performs initialization during the special WM_INITDIALOG message.

but the sample source code I'm using to garner some little experience is going against the rules...
Code:

static INT_PTR CALLBACK mainDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  switch(msg)
  {
    case WM_INITDIALOG:
    {
   
    }

    case WM_DESTROY: // this should not be possible from the definition no???
    {
   
    }

    case WM_CLOSE:
    {
     
    }

    case WM_COMMAND:
    {
     
      }
   
    }

    default:
      return FALSE;
  }
 
  return TRUE;
}

and we can clearly noticed the dialogprocedure is not returning a BOOL..
SO WHAT IS WHAT AND WHAT IS WHAT NOT??? thanks in advance to all who help...

scoping?

$
0
0
what is this please ?
the part I don't understand I commented out ...

Code:

class WinException
{
public:
    WinException (char* msg)
                : _err (GetLastError()), _msg(msg) // what trick is this? the : ??
    {}
    DWORD GetError()
                const { return _err; }

    char* GetMessage ()
                const { return _msg; }  // what is constant here? the return value?
private:
    DWORD _err;
    char* _msg;
};

and here too..but this time not on the constructor but on the class itself...I guess this is a c++ trick..

Code:

class WindowClass : public WNDCLASSEX // here ?
{
public:
    WindowClass (WNDPROC WndProc, char const * className, HINSTANCE hInst);
    void Register ()
    {
        if (RegisterClassEx (this) == 0)
            throw WinException ("RegisterClassEx");
    }
};

I understand a class has been made to create a window objects of type WNDCLASSEX.. but that trick there I don't understand...


what does it mean if the scope operator is used in a function like this? does it creates a sort of namespace or something?
[CODE]
void Show ( int nCmdShow )
{
::ShowWindow ( _hwnd, nCmdShow );
::UpdateWindow ( _hwnd );
}
[CODE/]

Mystery of the Modeless Dialog

$
0
0
I am looking at some code similar to this. I have theories as to
why the destructor is never called. In my opinion, the dialog does go
out of scope...the manager object should automatically delete it.
Code:

void ShowSearchDialog(void)
{
  uniqe_ptr<CModeLess> m_pmodeless(new CModeLess(this));
  m_pmodeless->Create(CModeLess::IDD);
  m_pmodeless->ShowWindow(SW_SHOW);       
}

In the dialog, based on some query results certain controls are disabled.

The next time the function is called the same controls are disabled even
if the query did not return the state that causes the controls to be disabled
again.

#1 Why doesn't the destructor get called?
#2 Why is the object hanging around?
#3 Why does the same object appear to be
reconnecting to the pointer on subsequent calls?:sick:

win32: i need 1 sugestion

$
0
0
i have 1 form with 1 richedit class control, inside of 1 class. when i create class object, the constructor is called, but don't get time for change the create variable function(lambda). so what is the best way for call the create variable function(lambda)?

IDE for winapi

$
0
0
are there other great ide'S for winapi other than visual studio and can one advice from experience? I'm having a hell of a time with visual studio...not seeing includes files sitting right in the source folder, problems with linker ecc..things I've never seen while using code blocks with normal c/c++ coding..

windows regsrv32

$
0
0
Hi, i have no idea how exactly this process work. When i successfully registered dll library, i have not seen any change. I try register dll, what is already registered, what make this process when
1) current library has the same version, but another path?
2) current library has newer version
3) current library has older version
Registry changes should be immediate or take effect after restart?
It depends if the library is currently used?

function in kernel32 not found ???

$
0
0
so I have a define.h like this
Code:

//define.h
#define MAK(dll, api)                ::api

and a filesystem.cpp file like this
Code:

...............
...............
 if( MAK(kernel32, GetFileSizeEx)(mem->file, &liSize) && liSize.HighPart == 0 )
  {.......}

I'm getting the error
Quote:

||=== Build: Debug in (compiler: GNU GCC Compiler)

error: '::GetFileSizeEx' has not been declared|
note : in expansion of macro 'MAK'
I'm using code::blocks, how do I go about this error?

msdn "desktops apps only"

$
0
0
Ok so I'm working on my first serious windows app,
but sometimes I have problems calling certain functions and checking on msdn, I sometimes noticed the specification
"desktops apps only"...

...how is the differentiation done between desktop app and non desktop apps? is there a certain line of particular command to insert ?
I think one should be able to write a simple app without specifying a priori if is a desktop app or not...anyway..over to you seasoned windows programmers...
Viewing all 583 articles
Browse latest View live