c语言如何获取指定窗口的确定按钮在屏幕上的坐标

c语言如何获取指定窗口的确定按钮在屏幕上的坐标,第1张

BOOL GetWindowRect(HWND hWnd,LPRECT lpRect);

返回指定窗口的边框矩形的尺寸。该尺寸以相对于屏幕坐标左上角的屏幕坐标给出。

hWnd hOK = GetDlgItem(hDlg,IDOK);

RECT rt;

GetWindowRect(hOK,&rt);

<template>

  <div>

    <el-input

      v-model="value"

      placeholder="请输入"

      style="width: 300px;"

      ref="commonDivContent"

      @contextmenunative="openMenu($event)"

       //组件api失焦事件

      @on-blur= "blurEvent($event)"

    ></el-input>

    <div

      v-if="menuFlag"

      ref="commonMouseRightMenu"

      :id="rightMenuId"

      class="hws-right-menu"

      :style="style"

    >

      <!-- <div class="hws-copy" v-if="copyData && isNeedCopyContent">

        <div class="hws-copy-title">剪切板</div>

        <div class="hws-copy-content" @click="insert(copyData)">{{copyData}}</div>

      </div> -->

      <ul>

        <li

        v-for="item in list"

        :key="itemid || itemvalue"

        :ref="itemid || itemvalue"

        @click="insert(itemvalue)"

        >

          <span>{{ itemname }}</span>

        </li>

      </ul>

    </div>

  </div>

</template>

<script>

  export default {

    components: {CommonMouseMenu},

    data() {

      return {

        templateParamData: 'fsdfhaksdjhf',

        list: [

          {

            name: '插入年份<yyyy>(如2009)',

            value: '<yyyy>'

          },

          {

            name: '插入年份<yy>(如09)',

            value: '<yy>'

          },

          {

            name: '插入月份<mm>(如02)',

            value: '<mm>'

          },

          {

            name: '插入月份<fmmm>(如2)',

            value: '<fmmm>'

          },

          {

            name: '插入日<dd>(如05日)',

            value: '<dd>'

          },

          {

            name: '插入日<fmdd>(如5日)',

            value: '<fmdd>'

          }

        ],

        menuFlag: false,

        value: '你今天也超级棒',

        style: {

          left: 0,

          top: 0

        },

        rightMenuRange: {},

       //失焦之后记录坐标位置值

        blurIndex: null

      }

    },

    computed: {

      rightMenuId() {

        return 'rightMenuId-' + thisid

      }

    },

    methods: {

      openMenu(e) {

        epreventDefault()

        // consolelog(e)

        thismenuFlag = true

        // thismenuFlag = true

        // // 当前浏览器窗口宽度跟高度

        const clientWidth = documentbodyclientWidth

        const clientHeight = documentbodyclientHeight

        // // 打开右键菜单

        this$nextTick(() => {

          const commonMouseRightMenu = documentgetElementById(thisrightMenuId)

          const rightMenuWidth = commonMouseRightMenuoffsetWidth || 210

          // // 鼠标点的坐标

          // clientX 事件属性返回当事件被触发时鼠标指针相对于浏览器页面(或客户区)的水平坐标

          const oX = eclientX + rightMenuWidth > clientWidth  eclientX - rightMenuWidth : eclientX

          const oY = eclientY + 200 > clientHeight  eclientY - 100 : eclientY

          // let el = this$refscommonDivContent

          // consolelog(el)

          // 记录鼠标光标的位置

          thisrightMenuRange = windowgetSelection()getRangeAt(0)

          // 右键菜单出现后的位置

          thisstyleleft = oX + 'px'

          thisstyletop = oY + 'px'

        })

      },

      // 鼠标插入数据 *** 作

      insert(text) {

        this$nextTick(() => {

          let str = thisvaluetoString()

          thisvalue = strslice(0, thisblurIndex) + text + strslice(thisblurIndex)

        })

      },

      blurEvent(e) {

        thisblurIndex = esrcElementselectionStart

      }

    }

  }

</script>

<style lang="scss" scoped>

hws-right-menu {

    position: fixed;

    left: 0;

    top: 0;

    height: auto;

    max-height: 200px;

    min-width: 210px;

    background-color: white;

    box-shadow: 2px 5px 6px #c2c1c2;

    display: block;

    border-radius: 2px;

    overflow-y: auto;

    border: 1px solid lightgrey;

  }

</style>

模块文件VUE

<template>

  <div v-if="showDialog" class="dialog" @touchmoveprevent>

    <div v-if="showDialog" class="back-drop"></div>

    <div class="alert" :class="{'alert-active':showDialogActive,'alert-big':big,'alert-middle':middle}" :style="'width:'+width+'px'">

      <div class="title">

        {{title}}

        <div class="iconfont close" @click="close"></div>

      </div>

      <div class="dialog-content">

        <slot></slot>

      </div>

    </div>

  </div>

</template>

<script>

import { setTimeout } from "timers";

export default {

  name: "v-templateCreat",

  props: {

    title: {

      type: String,

      default: "温馨提示"

    },

    cancelText: {

      type: String,

      default: "取消"

    },

    doneText: {

      type: String,

      default: "确定"

    },

    middle:{

      type:Boolean,

      default:false

    },

    big:{

      type:Boolean,

      default:false

    },

    show: {

      type: Boolean,

      default: false

    },

    dismiss: {

      type: Boolean,

      default: false

    },

    width: {

      default: 498

    },

    open:Boolean

  },

  data() {

    return {

      showDialog: false,

      message: "",

      cancel: false,

      value: "",

      templateCreat: false,

      showDialogActive: false

    };

  },

  methods: {

    close() {

      thisshowDialogActive = false;

      this$emit('update:open', false);

      setTimeout(() => (thisshowDialog = false), 320);

    },

    openFn(){

      thisshowDialog = true;

      setTimeout(() => (thisshowDialogActive = true));

    }

  },

  watch: {

    open:function(data){

      if(data) thisopenFn();

      if(!data) thisclose();

    },

    show: function(data) {

      thisopenFn();

    },

    dismiss: function() {

      thisclose();

    },

  },

  mounted(){

  }

};

</script>

<style lang="scss">

@import "/filters/css/allcss";

dialog {

  position: fixed;

  top: 0;

  bottom: 0;

  left: 0;

  right: 0;

  width: 100%;

  height: 100%;

  background: rgba(0, 0, 0, 0);

  z-index: 106;

  iconfont {

    float: right;

    cursor: pointer;

    color: #9b9b9b;

  }

  back-drop {

    position: fixed;

    top: 0;

    bottom: 0;

    left: 0;

    right: 0;

    width: 100%;

    height: 100%;

    background: rgba(0, 0, 0, 04);

    z-index: 106;

  }

  alert {

    width: 498px;

    min-height: 260px;

    // overflow-y: scroll;

    background: #fff;

    left: calc(50% - 249px);

    top: calc(50% - 280px);

    position: fixed;

    z-index: -1;

    transform: scale(123);

    opacity: 0;

    transition: all 032s;

    position: relative;

    title {

      height: 44px;

      width: 100%;

      padding: 0 20px;

      -webkit-box-sizing: border-box;

      box-sizing: border-box;

      line-height: 44px;

      background: #f2f2f2;

      -webkit-box-align: center;

      -ms-flex-align: center;

      align-items: center;

      font-size: 16px;

    }

    message {

      padding: 18px;

      min-height: 100px;

      overflow: auto;

    }

  }

  alert-middle{

    width:614px !important;

    left:calc(50% - 307px);

  }

  alert-big{

    width:748px !important;

    left:calc(50% - 374px);

  }

  alert-active {

    z-index: 9999;

    transform: scale(1);

    opacity: 1;

  }

}

</style>

////////////////////////////////

使用

import templateCreat from "@/components/templateCreat";

components: {

    templateCreat

  },

<!-- 店铺地址 -->

    <templateCreat

      :opensync="creatShowTemplate"

      title="店铺地址"

      :width="450"

    >

      <div class="exampleCenten">

        <div class="flex">

          <div class="leftTxt">所在地区</div>

          <div class="rightViewImg">

            <el-cascader

              style="width:310px;height:40px;"

              size="large"

              :options="regionOptions"

              v-model="formselectedOptions"

              @change="addressChange"

            ></el-cascader>

          </div>

        </div>

        <div class="flex">

          <div class="leftTxt"></div>

          <div class="rightViewImg">

            <div class="amapsView">

              <div style="padding:0 0 10px;">确认坐标,方便到店消费</div>

              <div class="amaps" :style="events'width:300px;height:240px;':''">

                <el-amap

                  ref="map"

                  vid="amapDemo"

                  :amap-manager="amapManager"

                  :center="center"

                  :zoom="zoom"

                  :plugin="plugin"

                  :events="events"

                  class="amap-demo"

                ></el-amap>

                <div class="amapsSon"></div>

              </div>

              <div style="padding:10px 0;width:300px;">{{formaddress}}</div>

            </div>

          </div>

        </div>

      </div>

      <div class="flex msgboxBtns">

        <el-button type="primary" style="width:100px;border-radius:0;" @click="shopSiteClick">保存</el-button>

      </div>

    </templateCreat>

import VueAMap from "vue-amap";

VueAMapinitAMapApiLoader({

  key: "e1dedc6bdd765d46693986ff7ff969f4",

  plugin: [

    "AMapAutocomplete", //输入提示插件

    "AMapPlaceSearch", //POI搜索插件

    "AMapScale", //右下角缩略图插件 比例尺

    "AMapOverView", //地图鹰眼插件

    "AMapToolBar", //地图工具条

    "AMapMapType", //类别切换控件,实现默认图层与卫星图、实施交通图层之间切换的控制

    "AMapPolyEditor", //编辑 折线多,边形

    "AMapCircleEditor", //圆形编辑器插件

    "AMapGeolocation" //定位控件,用来获取和展示用户主机所在的经纬度位置

  ],

  uiVersion: "10"

});

let amapManager = new VueAMapAMapManager();

data() {

    let self = this;

    return {

amapManager, //地图

      regionOptions: regionData,

      zoom: 12,

      center: [],

      getCertificationData: "",

      uploadActions: "",

      uploadType: "",

      initShow: false,

       form:{

address:‘’} //地址

      plugin: [

        {

          pName: "Geolocation",

          events: {

            init(o) {

              if (!selfinitShow) {

                selfinitShow = true;

                // o 是高德地图定位插件实例

                ogetCurrentPosition((status, result) => {

                  if (result && resultposition) {

                    consolelog(result);

                    selfformlongitude = resultpositionlng;

                    selfformlatitude = resultpositionlat;

                    selfcenter = [selfformlongitude, selfformlatitude];

                    selfformaddress = resultformattedAddress;

                  }

                });

              }

            }

          }

        }

      ],

      events: {

        init: o => {

          ogetCity(result => {});

        },

        moveend: () => {},

        zoomchange: () => {},

        dragend: e => {

          var lgt = this$refsmap$$getCenter();

          selfformlatitude = lgt[1];

          selfformlongitude = lgt[0];

          selfasdasdashowswxcasd = false;

          selfcenter = [selfformlongitude, selfformlatitude];

          // 这里通过高德 SDK 完成。

          var geocoder = new AMapGeocoder({

            radius: 1000,

            extensions: "all"

          });

          geocodergetAddress(this$refsmap$$getCenter(), function(

            status,

            result

          ) {

            if (status === "complete" && resultinfo === "OK") {

              if (result && resultregeocode) {

                selfcenter = [selfformlongitude, selfformlatitude];

                selfformaddress = resultregeocodeformattedAddress;

              }

            }

          });

        }

      },

}

使用while函数来循环,下面是一个计算交点的autolisp代码:

(defun c:tes ( / &k1 &kw1 &ss1 &ss2 i x)

 (setvar "cmdecho" 0)

 (setvar "blipmode" 0)

 (if (null vlax-dump-object) (vl-load-com) )

 (princ "\n请选择曲线")

 (if (setq &kw1 (ssget '((0  "LINE,ARC,CIRCLE,ELLIPSE,HELIX"))))

  (progn

   (setq &ss1 '() i -10)

   (while (setq &k1 (ssname &kw1 (setq i (1+ i))))

    (setq &ss1 (cons &k1 &ss1));提取对象

   );while

   (while (and (setq &k1 (car &ss1)) (setq &ss1 (cdr &ss1)));计算这条曲线与其他对象的交点

    (setq &ss2 (apply 'append (vl-remove-if '(lambda (x) (= x nil))

    (mapcar '(lambda (x) (acet-geom-intersectwith &k1 x 0)) &ss1))))

    ;&ss2是计算得到的交点,没有交点的话是nil

   );while;2

  )

 )

 (princ)

)

仅提供解决思路。不提供代码,API请自己找齐。

这样以后你遇到类似问题可以自行解决。

以下为思路,看不懂请自己琢磨相关逻辑和API作用。

1GetCursorPos 获取鼠标坐标 设获得的坐标为t_pos

2WindowFromPoint 获取t_pos坐标指向的窗体 设获得的窗体句柄为hwnd

3GetWindowRect 根据hwnd获取对应窗体坐标。此时t_pos与窗体坐标相减可以初步计算得相对坐标(包括标题栏等),设此时计算得坐标为pos

4GetWindowLong 获取样式,判断是否存在WS_BORDER(是否有边框)

方法:

假设GetWindowLong,获取的样式保存在style中,则if style or WS_BORDER=style then 存在WS_BORDER else 不存在WS_BORDER

如果存在WS_BORDER即有边框,则再调用GetSystemMetrics得到边框和标题栏宽度高度,然后pos与之相减(减掉边框)得到坐标相对于客户区的坐标

如果不存在WS_BORDER,则pos直接就是相对于客户区的坐标(无边框)

以上就是关于c语言如何获取指定窗口的确定按钮在屏幕上的坐标全部的内容,包括:c语言如何获取指定窗口的确定按钮在屏幕上的坐标、input组件中框获取鼠标右击坐标并插入文本、VUE 模块化d框 获取地图中心位置坐标地址等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9780606.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-01
下一篇2023-05-01

发表评论

登录后才能评论

评论列表(0条)

    保存